#include "Anna.h"
#include <bits/stdc++.h>
typedef int ll;
using namespace std;
namespace {
ll N;
ll mp[200][200];
ll flag[200][200];
bool chk(ll i, ll j) {
return 0 <= i && i < N && 0 <= j && j < N;
}
} // namespace
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
::N = N;
ll i, j, k;
vector<vector<ll>> v(3, vector<ll>(3));
v[(R[0] + 1) % 3][(C[0] + 1) % 3] = 1;
v[(R[1] + 1) % 3][(C[1]) % 3] = 1;
v[(R[2] + 1) % 3][(C[2] + 2) % 3] = 1;
v[(R[3]) % 3][(C[3] + 1) % 3] = 1;
v[(R[4]) % 3][(C[4] + 2) % 3] = 1;
v[(R[5] + 2) % 3][(C[5] + 1) % 3] = 1;
v[(R[6] + 2) % 3][(C[6] + 2) % 3] = 1;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
if (!v[i][j]) goto a;
}
}
a:
ll p = i, q = j;
for (i = p; i < N; i += 3) {
for (j = q; j < N; j += 3) {
mp[i][j] = 12;
if (chk(i - 1, j - 1)) mp[i - 1][j - 1] = 0;
if (chk(i - 1, j)) mp[i - 1][j] = 1;
if (chk(i - 1, j + 1)) mp[i - 1][j + 1] = 2;
if (chk(i, j - 1)) mp[i][j - 1] = 3;
if (chk(i, j + 1)) mp[i][j + 1] = 4;
if (chk(i + 1, j - 1)) mp[i + 1][j - 1] = 5;
if (chk(i + 1, j)) mp[i + 1][j] = -1;
if (chk(i + 1, j + 1)) mp[i + 1][j + 1] = 6;
}
}
vector<ll> asdf(13);
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
ll f;
if (0 <= mp[i][j] && mp[i][j] <= 6) {
f = mp[i][j];
ll r = R[f];
ll c = C[f];
if (max(abs(r - i), abs(c - j)) <= 1) {
if (r == i - 1 && c == j - 1) flag[i][j] = 5;
else if (r == i - 1 && c == j) flag[i][j] = 6;
else if (r == i - 1 && c == j + 1) flag[i][j] = 7;
else if (r == i && c == j - 1) flag[i][j] = 8;
else if (r == i && c == j + 1) flag[i][j] = 9;
else if (r == i + 1 && c == j - 1) flag[i][j] = 10;
else if (r == i + 1 && c == j) flag[i][j] = 11;
else if (r == i + 1 && c == j + 1) flag[i][j] = 12;
}
else {
if (r + 1 < i) flag[i][j] = 1;
else if (i + 1 < r) flag[i][j] = 2;
else if (c < j) flag[i][j] = 3;
else flag[i][j] = 4;
}
asdf[flag[i][j]] = 1;
}
}
}
ll c;
for (i = 5; i <= 12; i++) if (asdf[i] == 0) break;
c = i;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (mp[i][j] == -1) SetFlag(i, j, c - 4);
else if (flag[i][j] == 0) SetFlag(i, j, 12);
else if (flag[i][j] > c) SetFlag(i, j, flag[i][j] - 1);
else SetFlag(i, j, flag[i][j]);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
/*
3
140
2
*/
namespace {
int variable_example = 1;
ll f(pair<ll, ll> p) {
if (p.first == p.second) return 4;
if (p.first < 0) return 3;
if (p.first > 0) return 2;
if (p.second > 0) return 0;
else return 1;
}
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
vector<ll> ret(7);
ll c;
for (c = 0; c < 9; c++) if (value[c] == 12) break;
ll x = value[(c + 3) % 9] + 4;
ll xl = (c + 3) % 9;
ll i;
vector<pair<ll, ll>> loc(9);
for (i = 0; i < 9; i++) {
if (i == c || i == xl) continue;
if (value[i] >= x) value[i]++;
if (value[i] == 1) loc[i] = { -3, 0 };
if (value[i] == 2) loc[i] = { 3, 0 };
if (value[i] == 3) loc[i] = { 0, -3 };
if (value[i] == 4) loc[i] = { 0, 3 };
if (value[i] == 5) loc[i] = { -1, -1 };
if (value[i] == 6) loc[i] = { -1, 0 };
if (value[i] == 7) loc[i] = { -1, 1 };
if (value[i] == 8) loc[i] = { 0, -1 };
if (value[i] == 9) loc[i] = { 0, 1 };
if (value[i] == 10) loc[i] = { 1, -1 };
if (value[i] == 11) loc[i] = { 1, 0 };
if (value[i] == 12) loc[i] = { 1, 1 };
loc[i].first += i / 3;
loc[i].second += i % 3;
loc[i].first--;
loc[i].second--;
}
ret[0] = f(loc[(c + 5) % 9]);
ret[1] = f(loc[(c + 6) % 9]);
ret[2] = f(loc[(c + 7) % 9]);
ret[3] = f(loc[(c + 8) % 9]);
ret[4] = f(loc[(c + 1) % 9]);
ret[5] = f(loc[(c + 2) % 9]);
ret[6] = f(loc[(c + 4) % 9]);
return ret;
}
Compilation message
Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:19:11: warning: unused variable 'k' [-Wunused-variable]
19 | ll i, j, k;
| ^
Bruno.cpp:14:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
14 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
284 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |