Submission #386457

#TimeUsernameProblemLanguageResultExecution timeMemory
386457LucaDantasNavigation 2 (JOI21_navigation2)C++17
75 / 100
962 ms1128 KiB
#include "Anna.h" #include <vector> #include <cstdio> namespace { std::vector<int> R, C; int get(int r, int c) { return r%3 + 3*(c%3); } int tipo(int r, int c) { int t = get(r, c); if(t == 0) return 14; if(t == 8) return 1; --t; if(C[t] > c+1) return 1; if(C[t] < c-1) return 2; if(R[t] > r+1) return 3; if(R[t] < r-1) return 4; return 5 + R[t] - (r-1) + 3 * (C[t] - (c-1)); } } void Anna(int N, int K, std::vector<int> Ri, std::vector<int> Ci) { R = Ri; C = Ci; for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { SetFlag(r, c, tipo(r, c)); } } }
#include "Bruno.h" #include <vector> #include <cstdio> namespace { int tipo[3][3], mat[3][3]; bool valid(int a) { return a >= 0 && a <= 2; } void fill(int r, int c) { for(int i = -2; i <= 2; i++) { for(int j = -2; j <= 2; j++) { if(valid(r+i) && valid(c+j)) tipo[r+i][c+j] = (i+3)%3 + 3*((j+3)%3); } } } int get(int r, int c, int v) { r = 2-r; c = 2-c; int x = v%3, y = v/3; if(y > c) return 1; if(y < c) return 2; if(x > r) return 3; if(x < r) return 4; return 5; } } std::vector<int> Bruno(int K, std::vector<int> value) { std::vector<int> ans(K, 0); for(int r = 0; r < 3; r++) for(int c = 0; c < 3; c++) if(value[3*r + c] == 14) {fill(r, c); break;} for(int r = 0; r < 3; r++) for(int c = 0; c < 3; c++) mat[r][c] = value[3*r + c]; for(int r = 0; r < 3; r++) { for(int c = 0; c < 3; c++) { if(tipo[r][c] == 0 || tipo[r][c] == 8) continue; if(mat[r][c] < 5) ans[tipo[r][c]-1] = mat[r][c] - 1; else ans[tipo[r][c]-1] = get(r, c, mat[r][c] - 5) - 1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...