Submission #533323

#TimeUsernameProblemLanguageResultExecution timeMemory
533323fhvirusNavigation 2 (JOI21_navigation2)C++17
75 / 100
873 ms936 KiB
#include "Anna.h" #include <cmath> #include <vector> namespace { const int kMark = 14; std::vector<std::vector<int>> flag; void init(const int& N) { flag.assign(N, std::vector<int>(N, 0)); } int get_val(const int& i, const int& j, const int& r, const int& c) { if (j <= c - 2) return 10; if (j >= c + 2) return 11; if (i <= r - 2) return 12; if (i >= r + 2) return 13; int di = i - r, dj = j - c; return (di + 1) * 3 + (dj + 1) + 1; } void solve(const int& N, const int& K, const std::vector<int>& R, const std::vector<int>& C) { for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) { int k = (i % 3) * 3 + (j % 3); flag[i][j] = (k < 7 ? get_val(i, j, R[k], C[k]) : (k == 8 ? kMark : 1)); } } } // namespace void Anna(int N, int K, std::vector<int> R, std::vector<int> C) { init(N); solve(N, K, R, C); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) SetFlag(i, j, flag[i][j]); }
#include "Bruno.h" #include <vector> #include <iostream> namespace { const int kMark = 14; int judge(const int& i, const int& j, const int& r, const int& c) { if (i == r and j == c) return 4; if (j < c) return 0; if (j > c) return 1; if (i < r) return 2; if (i > r) return 3; return -1; } } // namespace std::vector<int> Bruno(int K, std::vector<int> value) { int mark_i, mark_j; for (int i = 0; i < 9; ++i) if (value[i] == kMark) { mark_i = i / 3; mark_j = i % 3; } std::vector<int> res(K); for (int dk = 0; dk < 9; ++dk) { int i = (dk / 3 + 2 - mark_i) % 3, j = (dk % 3 + 2 - mark_j) % 3; int k = i * 3 + j; if (i * 3 + j >= 7) continue; if (value[dk] >= 10) res[k] = value[dk] - 10; else { int r = dk / 3 + (1 - (value[dk] - 1) / 3); int c = dk % 3 + (1 - (value[dk] - 1) % 3); res[k] = judge(1, 1, r, c); } } return res; }

Compilation message (stderr)

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:30:54: warning: 'mark_j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |   int i = (dk / 3 + 2 - mark_i) % 3, j = (dk % 3 + 2 - mark_j) % 3;
      |                                          ~~~~~~~~~~~~^~~~~~~~~
Bruno.cpp:30:23: warning: 'mark_i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |   int i = (dk / 3 + 2 - mark_i) % 3, j = (dk % 3 + 2 - mark_j) % 3;
      |           ~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...