Submission #525201

#TimeUsernameProblemLanguageResultExecution timeMemory
525201amunduzbaevNavigation 2 (JOI21_navigation2)C++17
42 / 100
861 ms1108 KiB
#include "Anna.h" #include "bits/stdc++.h" using namespace std; void Anna(int n, int k, vector<int> r, vector<int> c) { vector<vector<int>> f(n, vector<int>(n, -1)); vector<vector<int>> t(n, vector<int>(n)); for(int i=0;i<k;i++) t[r[i]][c[i]] = i + 1; //~ for(int i=0;i<n;i++){ //~ for(int j=0;j<n;j++){ //~ cout<<t[i][j]<<" "; //~ } cout<<"\n"; //~ } cout<<"\n"; int ch[9][2] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1} }; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ int in = ((i%3) * 3 + j) % 7; if(c[in] > j + 1){ f[i][j] = 0; } else if(r[in] > i + 1){ f[i][j] = 2; } else if(c[in] < j - 1){ f[i][j] = 1; } else if(r[in] < i - 1){ f[i][j] = 3; } else { for(int t=0;t<9;t++){ int x = i + ch[t][0], y = j + ch[t][1]; if(r[in] == x && c[in] == y){ f[i][j] = t + 4; } } } f[i][j] = f[i][j] * 7 + in; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ assert(~f[i][j]); SetFlag(i, j, f[i][j] + 1); } } }
#include "Bruno.h" #include "bits/stdc++.h" using namespace std; vector<int> Bruno(int k, vector<int> val) { vector<int> r(k); int ch[9][2] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1} }; //~ for(int i=0;i<3;i++){ //~ for(int j=0;j<3;j++){ //~ cout<<val[i*3+j] % 7<<" "; //~ } cout<<"\n"; //~ } cout<<"\n"; //~ for(int i=0;i<3;i++){ //~ for(int j=0;j<3;j++){ //~ cout<<val[i*3+j] / 7<<" "; //~ } cout<<"\n"; //~ } cout<<"\n"; for(int i=0;i<9;i++){ val[i]--; int in = val[i] % 7, f = val[i] / 7; if(f < 4) r[in] = f; else { f -= 4; int x = ch[i][0] + ch[f][0], y = ch[i][1] + ch[f][1]; if(y > 0) r[in] = 0; else if(x > 0) r[in] = 2; else if(y < 0) r[in] = 1; else if(x < 0) r[in] = 3; else r[in] = 4; } } //~ for(int i=0;i<k;i++) cout<<r[i]<<" "; //~ cout<<"\n"; return r; }
#Verdict Execution timeMemoryGrader output
Fetching results...