Submission #475096

#TimeUsernameProblemLanguageResultExecution timeMemory
475096aintaNavigation 2 (JOI21_navigation2)C++17
0 / 100
1 ms192 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; #define vc vector #define vi vector<int> #define si(x) ((int)x.size()) #define pb push_back #define fi first #define se second using pii = pair<int,int>; void Anna(int N, int K, std::vector<int> R, std::vector<int> C) { int chk[3][3] = {0}; int OO[3][3] = {0}; for(int i=0;i<7;i++){ chk[R[i]%3][C[i]%3]=1; } vc<pii>V; vc<pii>U; int NN[7]; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(!chk[i][j] && si(V) < 2){ V.pb({i,j}); } } } if(V[0] > V[1])swap(V[0],V[1]); if(V[0].fi == V[1].se){ if(V[0].fi==0 && V[1].se==2)swap(V[1],V[0]); } else if(V[0].fi==0 && V[1].se==2)swap(V[1],V[0]); auto [ax,ay] = V[0]; auto [bx,by] = V[1]; for(int i=0;i<3;i++)for(int j=0;j<3;j++)OO[i][j]=0; OO[ax][ay] = OO[bx][by] = -1; int c = 0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ int x = (ax + i)%3, y = (ay + j)%3; if(OO[x][y] != -1){ OO[x][y] = c++; } } } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(OO[i%3][j%3] != -1){ int a = OO[i%3][j%3]; if(i - R[a] > 1){ SetFlag(i,j,4); } else if(i - R[a] < -1){ SetFlag(i,j,3); } else if(j - C[a] > 1){ SetFlag(i,j,2); } else if(j - C[a] < -1){ SetFlag(i,j,1); } else{ SetFlag(i, j, 5 + OO[R[a]%3][C[a]%3]); } } else{ SetFlag(i, j, 12); } } } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; #define vc vector #define vi vector<int> #define si(x) ((int)x.size()) #define pb push_back #define fi first #define se second std::vector<int> Bruno(int K, std::vector<int> value) { vc<pii>V; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(value[i*3+j] == 12){ V.pb({i,j}); } } } int chk[3][3] = {0}; int OO[3][3] = {0}; if(V[0] > V[1])swap(V[0],V[1]); if(V[0].fi == V[1].se){ if(V[0].fi==0 && V[1].se==2)swap(V[1],V[0]); } else if(V[0].fi==0 && V[1].se==2)swap(V[1],V[0]); auto [ax,ay] = V[0]; auto [bx,by] = V[1]; for(int i=0;i<3;i++)for(int j=0;j<3;j++)OO[i][j]=0; OO[ax][ay] = OO[bx][by] = -1; int c = 0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ int x = (ax + i)%3, y = (ay + j)%3; if(OO[x][y] != -1){ OO[x][y] = c++; } } } vi R(7); for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ //printf("%d %d %d\n",i,j,OO[i][j]); int a = value[i*3+j]; if(OO[i][j]!=-1){ if(a<=4){ R[OO[i][j]] = a-1; } else{ a-=5; int xx, yy; for(int k=i-1;k<=i+1;k++){ for(int l=j-1;l<=j+1;l++){ if(OO[(k+3)%3][(l+3)%3] == a){ xx=k, yy=l; } } } int t = 4; if(1 > xx)t = 3; else if(1 < xx)t = 2; else if(1 > yy)t = 1; else if(1 < yy)t = 0; //printf("%d %d %d %d %d\n",a,i,j,xx,yy); R[OO[i][j]] = t; } } } } return R; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:24:9: warning: unused variable 'NN' [-Wunused-variable]
   24 |     int NN[7];
      |         ^~

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:22:9: warning: unused variable 'chk' [-Wunused-variable]
   22 |     int chk[3][3] = {0};
      |         ^~~
Bruno.cpp:69:26: warning: 'yy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   69 |                     else if(1 < yy)t = 0;
      |                          ^~
Bruno.cpp:67:26: warning: 'xx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |                     else if(1 < xx)t = 2;
      |                          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...