#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>
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 pos_mark;
for (int i = 0; i < 9; ++i)
if (value[i] == kMark) pos_mark = i;
std::vector<int> res(K);
for (int k, dk = 0; dk < 7; ++dk) {
k = (pos_mark + 1 + dk) % 9;
if (value[k] >= 10) res[dk] = value[k] - 10;
else {
int r = (k / 3) + (1 - (value[k] - 1) / 3);
int c = (k % 3) + (1 - (value[k] - 1) % 3);
res[dk] = judge(1, 1, r, c);
}
}
return res;
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:20:6: warning: 'pos_mark' may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | int pos_mark;
| ^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
264 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |