Submission #1010147

#TimeUsernameProblemLanguageResultExecution timeMemory
1010147UnforgettableplNavigation 2 (JOI21_navigation2)C++17
100 / 100
567 ms1756 KiB
#include "Anna.h" #include <vector> #include <bits/stdc++.h> using namespace std; namespace { vector<vector<int>> assignment = { {0,1,2}, {3,4,5}, {6,8,7}, }; } // namespace void Anna(int N, int K, std::vector<int> R, std::vector<int> C) { int offset_x=0; int offset_y=0; vector<vector<int>> flags(N,vector<int>(N)); re: vector<bool> used(14); assert(offset_x!=3); for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7 or assignment[(r+offset_x)%3][(c+offset_y)%3]==8){flags[r][c]=(r,c,13);continue;} auto ass = assignment[(r+offset_x)%3][(c+offset_y)%3]; if(abs(R[ass]-r)<=1 and abs(C[ass]-c)<=1){ if(R[ass]==r and C[ass]==c){ // Redo if(offset_y==2){ offset_x++; offset_y=0; } else offset_y++; goto re; } else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12); else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11); else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5); else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10); else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6); else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9); else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8); else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7); continue; } if(abs(R[ass]-r)<=1){ if(c<C[ass])flags[r][c]=(r,c,2); else if(C[ass]<c)flags[r][c]=(r,c,4); continue; } if(r<R[ass])flags[r][c]=(r,c,3); else if(R[ass]<r)flags[r][c]=(r,c,1); } } for(int i=0;i<N;i++)for(int j=0;j<N;j++)used[flags[i][j]]=true; for(int x=1;x<14;x++)if(!used[x]){ for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(flags[i][j]>=x)flags[i][j]--; for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(assignment[(i+offset_x)%3][(j+offset_y)%3]==8)flags[i][j]=x; for(int i=0;i<N;i++)for(int j=0;j<N;j++)SetFlag(i,j,flags[i][j]); return; } if(offset_y==2){ offset_x++; offset_y=0; } else offset_y++; goto re; }
#include "Bruno.h" #include <vector> #include <bits/stdc++.h> using namespace std; namespace { vector<pair<int,int>> idxlookup = { {0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {1,2}, {2,0}, {2,1}, }; } // namespace std::vector<int> Bruno(int K, std::vector<int> value) { vector<vector<int>> val = { {value[0],value[1],value[2]}, {value[3],value[4],value[5]}, {value[6],value[7],value[8]}, }; vector<int> ans(K, 0); int rowoffset = 0; if(val[0][0]==12 or val[0][1]==12 or val[0][2]==12)rowoffset=1; if(val[1][0]==12 or val[1][1]==12 or val[1][2]==12)rowoffset=2; if(val[2][0]==12 or val[2][1]==12 or val[2][2]==12)rowoffset=0; int coloffset = 0; if(val[(rowoffset+2)%3][1]==12 and val[(rowoffset+2)%3][2]==12)coloffset=0; else if(val[(rowoffset+2)%3][0]==12 and val[(rowoffset+2)%3][1]==12)coloffset=2; else if(val[(rowoffset+2)%3][0]==12 and val[(rowoffset+2)%3][2]==12)coloffset=1; else if(val[(rowoffset+2)%3][0]==12)coloffset=1; else if(val[(rowoffset+2)%3][1]==12)coloffset=2; else if(val[(rowoffset+2)%3][2]==12)coloffset=0; int unusedoffset = val[(idxlookup[7].first+rowoffset)%3][(idxlookup[7].second+coloffset)%3]; for(auto&i:val)for(int&j:i)if(j>=unusedoffset)j++; for(int i=0;i<K;i++){ int act_x = (idxlookup[i].first+rowoffset)%3; int act_y = (idxlookup[i].second+coloffset)%3; if(val[act_x][act_y]==1){ans[i]=3;continue;} if(val[act_x][act_y]==2){ans[i]=0;continue;} if(val[act_x][act_y]==3){ans[i]=2;continue;} if(val[act_x][act_y]==4){ans[i]=1;continue;} int where_x = act_x; int where_y = act_y; if(val[act_x][act_y]==12){where_x+=-1;where_y+=0;} if(val[act_x][act_y]==11){where_x+=-1;where_y+=-1;} if(val[act_x][act_y]==10){where_x+=0;where_y+=-1;} if(val[act_x][act_y]==6){where_x+=0;where_y+=1;} if(val[act_x][act_y]==5){where_x+=-1;where_y+=1;} if(val[act_x][act_y]==9){where_x+=1;where_y+=-1;} if(val[act_x][act_y]==8){where_x+=1;where_y+=0;} if(val[act_x][act_y]==7){where_x+=1;where_y+=1;} if(where_x==1 and where_y==1){ans[i]=4;continue;} if(where_x<1){ans[i]=3;continue;} if(where_x>1){ans[i]=2;continue;} if(where_y<1){ans[i]=1;continue;} if(where_y>1){ans[i]=0;continue;} } return ans; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:26:125: warning: left operand of comma operator has no effect [-Wunused-value]
   26 |             if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7 or assignment[(r+offset_x)%3][(c+offset_y)%3]==8){flags[r][c]=(r,c,13);continue;}
      |                                                                                                                             ^
Anna.cpp:26:129: warning: right operand of comma operator has no effect [-Wunused-value]
   26 |             if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7 or assignment[(r+offset_x)%3][(c+offset_y)%3]==8){flags[r][c]=(r,c,13);continue;}
      |                                                                                                                                 ^~
Anna.cpp:37:64: warning: left operand of comma operator has no effect [-Wunused-value]
   37 |                 else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12);
      |                                                                ^
Anna.cpp:37:68: warning: right operand of comma operator has no effect [-Wunused-value]
   37 |                 else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12);
      |                                                                    ^~
Anna.cpp:38:66: warning: left operand of comma operator has no effect [-Wunused-value]
   38 |                 else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11);
      |                                                                  ^
Anna.cpp:38:70: warning: right operand of comma operator has no effect [-Wunused-value]
   38 |                 else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11);
      |                                                                      ^~
Anna.cpp:39:66: warning: left operand of comma operator has no effect [-Wunused-value]
   39 |                 else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5);
      |                                                                  ^
Anna.cpp:39:70: warning: right operand of comma operator has no effect [-Wunused-value]
   39 |                 else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5);
      |                                                                      ^
Anna.cpp:40:64: warning: left operand of comma operator has no effect [-Wunused-value]
   40 |                 else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10);
      |                                                                ^
Anna.cpp:40:68: warning: right operand of comma operator has no effect [-Wunused-value]
   40 |                 else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10);
      |                                                                    ^~
Anna.cpp:41:64: warning: left operand of comma operator has no effect [-Wunused-value]
   41 |                 else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6);
      |                                                                ^
Anna.cpp:41:68: warning: right operand of comma operator has no effect [-Wunused-value]
   41 |                 else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6);
      |                                                                    ^
Anna.cpp:42:66: warning: left operand of comma operator has no effect [-Wunused-value]
   42 |                 else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9);
      |                                                                  ^
Anna.cpp:42:70: warning: right operand of comma operator has no effect [-Wunused-value]
   42 |                 else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9);
      |                                                                      ^
Anna.cpp:43:64: warning: left operand of comma operator has no effect [-Wunused-value]
   43 |                 else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8);
      |                                                                ^
Anna.cpp:43:68: warning: right operand of comma operator has no effect [-Wunused-value]
   43 |                 else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8);
      |                                                                    ^
Anna.cpp:44:66: warning: left operand of comma operator has no effect [-Wunused-value]
   44 |                 else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7);
      |                                                                  ^
Anna.cpp:44:70: warning: right operand of comma operator has no effect [-Wunused-value]
   44 |                 else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7);
      |                                                                      ^
Anna.cpp:48:42: warning: left operand of comma operator has no effect [-Wunused-value]
   48 |                 if(c<C[ass])flags[r][c]=(r,c,2);
      |                                          ^
Anna.cpp:48:46: warning: right operand of comma operator has no effect [-Wunused-value]
   48 |                 if(c<C[ass])flags[r][c]=(r,c,2);
      |                                              ^
Anna.cpp:49:47: warning: left operand of comma operator has no effect [-Wunused-value]
   49 |                 else if(C[ass]<c)flags[r][c]=(r,c,4);
      |                                               ^
Anna.cpp:49:51: warning: right operand of comma operator has no effect [-Wunused-value]
   49 |                 else if(C[ass]<c)flags[r][c]=(r,c,4);
      |                                                   ^
Anna.cpp:52:38: warning: left operand of comma operator has no effect [-Wunused-value]
   52 |             if(r<R[ass])flags[r][c]=(r,c,3);
      |                                      ^
Anna.cpp:52:42: warning: right operand of comma operator has no effect [-Wunused-value]
   52 |             if(r<R[ass])flags[r][c]=(r,c,3);
      |                                          ^
Anna.cpp:53:43: warning: left operand of comma operator has no effect [-Wunused-value]
   53 |             else if(R[ass]<r)flags[r][c]=(r,c,1);
      |                                           ^
Anna.cpp:53:47: warning: right operand of comma operator has no effect [-Wunused-value]
   53 |             else if(R[ass]<r)flags[r][c]=(r,c,1);
      |                                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...