编译没过wa---玄关求调

P2895 [USACO08FEB] Meteor Shower S

你用啥语言编译没过 本地没问题啊
by liuruiqing @ 2024-04-17 20:38:43


@[liuruiqing](/user/1118614) c++,用的是Dev_c++5.11
by lucy2012 @ 2024-04-17 20:43:35


@[liuruiqing](/user/1118614) 用的时候跳出了一堆东西
by lucy2012 @ 2024-04-17 20:45:06


??? 呵呵,我是 Dev_c++6.7.5 小版本请忽略 那你本地过了么
by liuruiqing @ 2024-04-17 20:45:22


你:用的时候跳出了一堆东西 我:??什么意思
by liuruiqing @ 2024-04-17 20:46:20


@[liuruiqing](/user/1118614) 说这个 ```cpp template<typename _Tp, typename _Compare> inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { //return __comp(__b, __a) ? __b : __a; if (__comp(__b, __a))//显示这里错了 return __b; return __a; } ```
by lucy2012 @ 2024-04-17 20:46:30


@[lucy2012](/user/1252442) 最上面#define min(x,y) x<y?x:y就可以过编译了。可能是没有自带函数导致的 ```cpp #include<bits/stdc++.h> using namespace std; #define min(x,y) x<y?x:y struct where{ int x,y; }; queue<where> q; int sum[310][310],when[310][310]; int d[5][2]={{0,0},{0,1},{1,0},{-1,0},{0,-1}}; void minn(int a,int b,int c){ if(a>=0&&b>=0) when[a][b]=min(when[a][b],c); } int main(){ int m,ans=100000; memset(sum,-1,sizeof(sum)); memset(when,0x7f,sizeof(when)); cin>>m; for(int i=1;i<=m;i++){ int x,y,t; cin>>x>>y>>t; min(x,min(y,t)); for(int k=0;k<=4;k++) min(x+d[k][0],min(y+d[k][1],t)); } q.push((where){0,0}); sum[0][0]=0; while(!q.empty()){ where u=q.front(); int ux=u.x,uy=u.y; q.pop(); for(int k=0;k<4;k++){ int x1=ux+d[k][0],y1=uy+d[k][1]; if(x1<0||y1<0||sum[x1][y1]!=-1||sum[ux][uy]+1>=when[x1][y1]) continue; sum[x1][y1]=sum[ux][uy]+1; where wh={x1,y1}; q.push(wh); } } for(int i=0;i<=305;i++){ for(int j=0;j<=305;j++){ if(sum[i][j]>1000&&sum[i][j]!=-1) ans=min(ans,sum[i][j]); } } if(ans==100000) cout<<-1; else cout<<ans; return 0; } ``` 但是编译完了还是错的
by LzxQwQ @ 2024-04-17 20:47:27


@[liuruiqing](/user/1118614) 本地没过
by lucy2012 @ 2024-04-17 20:47:38


啊我明白了 你写的代码使头文件出问题了。 ~~尽管我也这样过~~
by liuruiqing @ 2024-04-17 20:48:58


@[LzxQwQ](/user/678073) @[liuruiqing](/user/1118614) 找到问题了,自己用自己定义的minn时用成了min……QwQ
by lucy2012 @ 2024-04-17 20:50:55


| 下一页