Submission #503375

#TimeUsernameProblemLanguageResultExecution timeMemory
503375dooweyNavigation 2 (JOI21_navigation2)C++17
75 / 100
797 ms884 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; int dir[9][2] = {{-1, -1}, {-1, 0} ,{-1,+1},{0,-1},{0,0},{0,+1},{+1,-1},{+1,0},{+1,+1}}; void Anna(int n, int k, vector<int> R, vector<int> C) { int id; for(int i = 0 ; i < n; i ++ ){ for(int j = 0 ; j < n; j ++ ){ id = 3 * (i % 3) + (j % 3); if(id == 0){ SetFlag(i, j, 1); } else{ if(id >= 1 && id <= 7){ id -- ; if(C[id] - j >= 2){ SetFlag(i, j, 2); } else if(j - C[id] >= 2){ SetFlag(i, j, 3); } else if(R[id] - i >= 2){ SetFlag(i, j, 4); } else if(i - R[id] >= 2){ SetFlag(i, j, 5); } else{ int ci, cj; for(int d = 0; d < 9 ; d ++ ){ ci = i + dir[d][0]; cj = j + dir[d][1]; if(ci == R[id] && cj == C[id]){ SetFlag(i, j, 6 + d); break; } } } } else{ SetFlag(i, j, 2); } } } cout << "\n"; } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair int di[9][2] = {{-1, -1}, {-1, 0} ,{-1,+1},{0,-1},{0,0},{0,+1},{+1,-1},{+1,0},{+1,+1}}; vector<int> Bruno(int K, vector<int> value) { int p0 = 0, q0 = 0; for(int i = 0 ; i < 9 ; i ++ ){ if(value[i] == 1){ p0 = di[i][0]; q0 = di[i][1]; } } int n0, m0; int d0, d1; int id; vector<int> sol(7); int ii, jj; for(int i = 0 ; i < 9 ; i ++ ){ n0 = di[i][0]; m0 = di[i][1]; d0 = n0 - p0; d1 = m0 - q0; if(d0 < 0) d0 += 3; if(d1 < 0) d1 += 3; id = d0 * 3 + d1; if(id >= 1 && id <= 7){ if(value[i] >= 2 && value[i] <= 5){ sol[id - 1] = value[i] - 2; } else{ ii = n0 + di[value[i] - 6][0]; jj = m0 + di[value[i] - 6][1]; if(ii == 0 && jj == 0) sol[id - 1] = 4; else{ if(jj > 0) sol[id - 1] = 0; else if(jj < 0) sol[id - 1] = 1; else if(ii > 0) sol[id - 1] = 2; else if(ii < 0) sol[id - 1] = 3; } } } } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...