#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;
}
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
std::cerr << value[i * 3 + j] << " \n"[j == 2];
std::cerr << std::endl;
std::vector<int> res(K);
for (int dk = 0; dk < 9; ++dk) {
int di = (dk / 3 + 2 - mark_i) % 3, dj = (dk % 3 + 2 - mark_j) % 3;
int k = di * 3 + dj;
std::cerr << dk << ':' << k << std::endl;
if (di * 3 + dj >= 7) continue;
if (value[dk] >= 10) res[k] = value[dk] - 10;
else {
int r = di + (1 - (value[dk] - 1) / 3);
int c = dj + (1 - (value[dk] - 1) % 3);
res[k] = judge(1, 1, r, c);
}
}
for (int i = 0; i < K; ++i)
std::cerr << res[i] << ' ';
std::cerr << std::endl;
return res;
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:35:56: warning: 'mark_j' may be used uninitialized in this function [-Wmaybe-uninitialized]
35 | int di = (dk / 3 + 2 - mark_i) % 3, dj = (dk % 3 + 2 - mark_j) % 3;
| ~~~~~~~~~~~~^~~~~~~~~
Bruno.cpp:35:24: warning: 'mark_i' may be used uninitialized in this function [-Wmaybe-uninitialized]
35 | int di = (dk / 3 + 2 - mark_i) % 3, dj = (dk % 3 + 2 - mark_j) % 3;
| ~~~~~~~~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
196 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |