Submission #525216

#TimeUsernameProblemLanguageResultExecution timeMemory
525216amunduzbaevNavigation 2 (JOI21_navigation2)C++17
0 / 100
1 ms196 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; } } } if(in == 0){ f[i][j] += 13 * ((i%3) + 1); } } } 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; #define ar array vector<int> Bruno(int k, vector<int> val) { vector<int> r(k), ii(9); ar<int, 2> ch[9] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1} }; int is = 0; ar<int, 2> p = {-2}; for(int i=0;i<9;i++){ val[i]--; if(val[i] >= 13){ p = ch[i]; is = val[i] / 13 - 1; val[i] %= 13; } } assert(p[0] != -2); int tt[3][5][5] = { { {1, 2, 3, 4, 5}, {4, 5, 6, 0, 1}, {5, 6, 0, 1, 2}, {1, 2, 3, 4, 5}, {4, 5, 6, 0, 1} }, { {1, 2, 3, 4, 5}, {2, 3, 4, 5, 6}, {5, 6, 0, 1, 2}, {1, 2, 3, 4, 5}, {2, 3, 4, 5, 6} }, { {6, 0, 1, 2, 3}, {2, 3, 4, 5, 6}, {5, 6, 0, 1, 2}, {1, 2, 3, 4, 5}, {4, 5, 6, 0, 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<9;i++){ int x = -ch[i][0] + 2 + p[0], y = -ch[i][1] + 2 + p[1]; ii[i] = tt[is][x][y]; //~ cout<<ii[i]<<" "<<val[i] % 7<<endl; } for(int i=0;i<9;i++){ int in = ii[i], f = val[i]; //~ assert(in == 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...