#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
int cur[105][105];
bool seen[15];
int n;
void Anna(int N, int K, vector<int> R, vector<int> C) {
n = N;
bool valid = true;
// cout << "BRUH" << endl;
for (int offset = 0; offset < 9; offset++) {
// cout << offset << endl;
valid = true;
for (int i = 0; i < N; i++) {
if (!valid) break;
for (int j = 0; j < N; j++) {
if (!valid) break;
int dx = offset / 3;
int dy = offset % 3;
int nx = i + dx, ny = j + dy;
int equival = ((nx) % 3) * 3 + (ny) % 3;
if (equival == 8) {
// anchor point
cur[i][j] = 1e9;
} else if (equival == 7) {
// store val for later
cur[i][j] = -1;
} else {
int ndx = - R[equival] + i, ndy = - C[equival] + j;
if (ndx >= 2) {
cur[i][j] = 12;
} else if (ndy >= 2) {
cur[i][j] = 10;
} else if (ndx <= -2) {
cur[i][j] = 11;
} else if (ndy <= -2) {
cur[i][j] = 9;
} else {
cur[i][j] = (ndx + 1) * 3 + ndy + 2;
if (cur[i][j] == 9) {
valid = false;
break;
}
// if (cur[i][j] > 5) cur[i][j]--;
}
}
// cout << cur[i][j] << " " ;
}
}
if (valid) break;
}
assert(valid == true);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (cur[i][j] == 1e9 || cur[i][j] == -1) continue;
assert(cur[i][j] != 0);
seen[cur[i][j]] = true;
}
}
int skipval = -1;
for (int i = 1; i <= 12; i++) {
if (!seen[i]) {
skipval = i;
break;
}
}
// assert(skipval > 0);
// cout << skipval << endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (cur[i][j] == 1e9) {
SetFlag(i, j, 12);
} else if (cur[i][j] == -1) {
SetFlag(i, j, skipval);
} else {
if (cur[i][j] > skipval) cur[i][j]--;
SetFlag(i, j, cur[i][j]);
}
}
}
// cout << "BRUH" << endl;
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> Bruno(int K, vector<int> value) {
// cout << "Called " << endl;
int anchor = 0;
int dx, dy;
for (int i = 0; i < 9; i++) {
if (value[i] == 12) {
anchor = i;
dx = i / 3, dy = i % 3;
}
}
// for (int i =0 ; i < 9; i++) cout << value[i] << " ";
// cout << endl;
int skipped = value[dx * 3 + ((dy + 2) % 3)];
// cout << skipped << endl;
// cout << value[7] << " " << value[8] << endl;
vector<int> ans(K, 0);
for (int i = 0; i < 9; i++) {
if (value[i] == skipped || value[i] == 12) continue;
int ni = (i / 3 + 2 - dx) % 3, nj = (i % 3 + 2 - dy) % 3;
int equival = (ni * 3 + nj);
// cout << "equiv " << equival << endl;
// if (equival >= 8) assert(false);
if (value[i] >= skipped) value[i]++;
if (equival >= 7) continue;
if (value[i] >= 9) ans[equival] = value[i] - 9;
else {
int r = (i / 3) + (1 - (value[i]- 1) / 3);
int c = (i % 3) + (1 - (value[i]- 1) % 3);
if (1 == r && 1 == c) ans[equival] = 4;
else if (r < 1) ans[equival] = 3;
else if (c < 1) ans[equival] = 1;
else if (r > 1) ans[equival] = 2;
else if (c > 1) ans[equival] = 0;
}
}
return ans;
// cout << endl;
// return vector<int>(K, 0);
// assert(false);
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:8:13: warning: variable 'anchor' set but not used [-Wunused-but-set-variable]
8 | int anchor = 0;
| ^~~~~~
Bruno.cpp:30:60: warning: 'dy' may be used uninitialized in this function [-Wmaybe-uninitialized]
30 | int ni = (i / 3 + 2 - dx) % 3, nj = (i % 3 + 2 - dy) % 3;
| ~~~~~~~~~~~^~~~~
Bruno.cpp:30:33: warning: 'dx' may be used uninitialized in this function [-Wmaybe-uninitialized]
30 | int ni = (i / 3 + 2 - dx) % 3, nj = (i % 3 + 2 - dy) % 3;
| ~~~~~~~~~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |