Submission #241309

# Submission time Handle Problem Language Result Execution time Memory
241309 2020-06-23T19:35:19 Z dolphingarlic Robots (APIO13_robots) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define F(i,x,y) for(int i=x; i<y; i++)
using namespace std;const int I=250000;int n,h,w;char g[500][500];pair<int,int>E[500][500][4];int dp[500][500][9][9];vector<pair<int,int>>q[I];bool inside(int x,int y){return(x>=0&&y>=0&&x<h&&y<w&&g[x][y] !='x');}int main(){ios_base::sync_with_stdio(0);cin.tie(0);cin>>n>>w>>h;memset(dp,0x3f,sizeof(dp));F(i,0,h)F(j,0,w){cin>>g[i][j];if(g[i][j]-'0'>0&&g[i][j]-'0'<10){dp[i][j][g[i][j]-'1'][g[i][j]-'1']=0;}}F(i,0,h)F(j,0,w)if(g[i][j] !='x'){F(k,0,4){pair<int,int>p={i,j};int d=(k+(g[i][j]=='A')*3+(g[i][j]=='C'))%4;while(1){if(d==0){if(inside(p.first-1,p.second)) p.first--;else break;}else if(d==1){if(inside(p.first,p.second+1)) p.second++;else break;}else if(d==2){if(inside(p.first+1,p.second)) p.first++;else break;}else{if(inside(p.first,p.second-1)) p.second--;else break;}if(g[p.first][p.second]=='A') d=(d+3) % 4;if(g[p.first][p.second]=='C') d=(d+1) % 4;}E[i][j][k]=p;}}F(r,0,n){F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){F(d,k,l){dp[i][j][k][l]=min(dp[i][j][k][l],dp[i][j][k][d]+dp[i][j][d+1][l]);}}}F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){if(dp[i][j][k][l]<=I) q[dp[i][j][k][l]].push_back({i,j});}F(i,0,I){F(pair<int,int>p : q[i]){int x,y;tie(x,y)=p;if(dp[x][y][k][l]==i){F(d,0,4){int nx,ny;tie(nx,ny)=E[x][y][d];if(dp[nx][ny][k][l]>dp[x][y][k][l]+1){q[dp[nx][ny][k][l]=dp[x][y][k][l]+1].push_back({nx,ny});}}}}q[i].clear();}}}int ans=INT_MAX;F(i,0,h)F(j,0,w)ans=min(ans,dp[i][j][0][n-1]);cout<<(ans>I?-1:ans);return 0;}

Compilation message

robots.cpp:3:1171: error: macro "F" requires 3 arguments, but only 2 given
 using namespace std;const int I=250000;int n,h,w;char g[500][500];pair<int,int>E[500][500][4];int dp[500][500][9][9];vector<pair<int,int>>q[I];bool inside(int x,int y){return(x>=0&&y>=0&&x<h&&y<w&&g[x][y] !='x');}int main(){ios_base::sync_with_stdio(0);cin.tie(0);cin>>n>>w>>h;memset(dp,0x3f,sizeof(dp));F(i,0,h)F(j,0,w){cin>>g[i][j];if(g[i][j]-'0'>0&&g[i][j]-'0'<10){dp[i][j][g[i][j]-'1'][g[i][j]-'1']=0;}}F(i,0,h)F(j,0,w)if(g[i][j] !='x'){F(k,0,4){pair<int,int>p={i,j};int d=(k+(g[i][j]=='A')*3+(g[i][j]=='C'))%4;while(1){if(d==0){if(inside(p.first-1,p.second)) p.first--;else break;}else if(d==1){if(inside(p.first,p.second+1)) p.second++;else break;}else if(d==2){if(inside(p.first+1,p.second)) p.first++;else break;}else{if(inside(p.first,p.second-1)) p.second--;else break;}if(g[p.first][p.second]=='A') d=(d+3) % 4;if(g[p.first][p.second]=='C') d=(d+1) % 4;}E[i][j][k]=p;}}F(r,0,n){F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){F(d,k,l){dp[i][j][k][l]=min(dp[i][j][k][l],dp[i][j][k][d]+dp[i][j][d+1][l]);}}}F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){if(dp[i][j][k][l]<=I) q[dp[i][j][k][l]].push_back({i,j});}F(i,0,I){F(pair<int,int>p : q[i]){int x,y;tie(x,y)=p;if(dp[x][y][k][l]==i){F(d,0,4){int nx,ny;tie(nx,ny)=E[x][y][d];if(dp[nx][ny][k][l]>dp[x][y][k][l]+1){q[dp[nx][ny][k][l]=dp[x][y][k][l]+1].push_back({nx,ny});}}}}q[i].clear();}}}int ans=INT_MAX;F(i,0,h)F(j,0,w)ans=min(ans,dp[i][j][0][n-1]);cout<<(ans>I?-1:ans);return 0;}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
robots.cpp: In function 'int main()':
robots.cpp:3:1148: error: 'F' was not declared in this scope
 using namespace std;const int I=250000;int n,h,w;char g[500][500];pair<int,int>E[500][500][4];int dp[500][500][9][9];vector<pair<int,int>>q[I];bool inside(int x,int y){return(x>=0&&y>=0&&x<h&&y<w&&g[x][y] !='x');}int main(){ios_base::sync_with_stdio(0);cin.tie(0);cin>>n>>w>>h;memset(dp,0x3f,sizeof(dp));F(i,0,h)F(j,0,w){cin>>g[i][j];if(g[i][j]-'0'>0&&g[i][j]-'0'<10){dp[i][j][g[i][j]-'1'][g[i][j]-'1']=0;}}F(i,0,h)F(j,0,w)if(g[i][j] !='x'){F(k,0,4){pair<int,int>p={i,j};int d=(k+(g[i][j]=='A')*3+(g[i][j]=='C'))%4;while(1){if(d==0){if(inside(p.first-1,p.second)) p.first--;else break;}else if(d==1){if(inside(p.first,p.second+1)) p.second++;else break;}else if(d==2){if(inside(p.first+1,p.second)) p.first++;else break;}else{if(inside(p.first,p.second-1)) p.second--;else break;}if(g[p.first][p.second]=='A') d=(d+3) % 4;if(g[p.first][p.second]=='C') d=(d+1) % 4;}E[i][j][k]=p;}}F(r,0,n){F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){F(d,k,l){dp[i][j][k][l]=min(dp[i][j][k][l],dp[i][j][k][d]+dp[i][j][d+1][l]);}}}F(k,0,n-r){int l=k+r;F(i,0,h)F(j,0,w) if(g[i][j] !='x'){if(dp[i][j][k][l]<=I) q[dp[i][j][k][l]].push_back({i,j});}F(i,0,I){F(pair<int,int>p : q[i]){int x,y;tie(x,y)=p;if(dp[x][y][k][l]==i){F(d,0,4){int nx,ny;tie(nx,ny)=E[x][y][d];if(dp[nx][ny][k][l]>dp[x][y][k][l]+1){q[dp[nx][ny][k][l]=dp[x][y][k][l]+1].push_back({nx,ny});}}}}q[i].clear();}}}int ans=INT_MAX;F(i,0,h)F(j,0,w)ans=min(ans,dp[i][j][0][n-1]);cout<<(ans>I?-1:ans);return 0;}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ^