#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
bool used[3][3];
for (int x = 0; x<3; x++){
for (int y = 0; y<3; y++){
used[x][y] = false;
}
}
for (int x = 0; x<K; x++){
used[R[x]%3][C[x]%3] = true;
}
int offsetx,offsety;
for (int x = 0; x<3; x++){
for (int y = 0; y<3; y++){
if (!used[x][y]){
offsetx = x;
offsety = y;
}
}
}
int num1[N][N];
int num2[N][N];
for (int x = 0; x<N; x++){
for (int y = 0; y<N; y++){
num1[x][y] = -1;
num2[x][y] = -1;
}
}
for (int x = 0; x<K; x++){
num1[R[x]][C[x]] = x;
}
for (int r = 0; r < N; r++) {
for (int c = 0; c < N; c++) {
if (num1[r][c]==-1 && r%3==offsetx && c%3==offsety){
num1[r][c] = 7;
}
else if (num1[r][c]==-1) num1[r][c] = 8;
}
}
vector<pair<int,int> > offsets = {{1,0},{2,0},{0,1},{1,1},{2,1},{0,2},{1,2}};
for (int k = 0; k<K; k++){
for (int X = offsetx-3+offsets[k].first; X<N; X+=3){
if (X<0) continue;
for (int Y = offsety-3+offsets[k].second; Y<N; Y+=3){
if (Y<0) continue;
if (R[k]<X){
num2[X][Y] = 0;
}
else if (R[k]>X){
num2[X][Y] = 1;
}
else if (C[k]<Y){
num2[X][Y] = 2;
}
else if (C[k]>Y){
num2[X][Y] = 3;
}
if (R[k]==X-1 && C[k]==Y-1){
num2[X][Y] = 4;
}
else if (R[k]==X+1 && C[k]==Y-1){
num2[X][Y] = 5;
}
else if (R[k]==X-1&& C[k]==Y+1){
num2[X][Y] = 6;
}
else if (R[k]==X+1 && C[k]==Y+1){
num2[X][Y] = 7;
}
if (num2[X][Y]==-1) num2[X][Y] = 0;
}
}
}
for (int x = 0; x<N; x++){
for (int y = 0; y<N; y++){
if (num2[x][y]==-1) num2[x][y] = 0;
//if (x>=83 && x<=85 && y>=58 && y<=60) printf("%d %d = %d %d\n",x,y,num1[x][y],num2[x][y]);
SetFlag(x,y,num1[x][y]*8+num2[x][y]+1);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> Bruno(int K, std::vector<int> value) {
int num1[3][3];
int num2[3][3];
for (int i = 0; i<9; i++){
int x = i/3;
int y = i%3;
num1[x][y] = (value[i]-1)/8;
num2[x][y] = (value[i]-1)%8;
// printf("%d %d = %d %d\n",x,y,num1[x][y],num2[x][y]);
}
vector<int> res;
for (int x = 0; x<K; x++) res.push_back(-1);
int offsetx = -1; int offsety = -1;
for (int x = 0; x<3; x++){
for (int y = 0; y<3; y++){
if (num1[x][y]==7){
offsetx = x; offsety = y;
}
if (num1[x][y]<7){
if (x==0) res[num1[x][y]] = 3;
else if (x==2) res[num1[x][y]] = 2;
else if (y==0) res[num1[x][y]] = 1;
else if (y==2) res[num1[x][y]] = 0;
else res[num1[x][y]] = 4;
}
}
}
vector<pair<int,int> > offsets = {{1,0},{2,0},{0,1},{1,1},{2,1},{0,2},{1,2}};
for (int k = 0; k<K; k++){
if (res[k]!=-1) continue;
int casenum = num2[(offsetx+offsets[k].first)%3][(offsety+offsets[k].second)%3];
// printf("for k = %d, case = %d\n",k,casenum);
if (casenum==0){
res[k] = 3;
}
else if (casenum==1){
res[k] = 2;
}
else if (casenum==2){
res[k] = 1;
}
else if (casenum==3){
res[k] = 0;
}
else if (casenum==4){
res[k] = ((offsetx+offsets[k].first)%3==2)?1:3;
}
else if (casenum==5){
res[k] = ((offsetx+offsets[k].first)%3==0)?1:2;
}
else if (casenum==6){
res[k] = ((offsetx+offsets[k].first)%3==2)?0:3;
}
else if (casenum==7){
res[k] = ((offsetx+offsets[k].first)%3==0)?0:2;
}
}
return res;
}
Compilation message
Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:46:29: warning: 'offsetx' may be used uninitialized in this function [-Wmaybe-uninitialized]
46 | for (int X = offsetx-3+offsets[k].first; X<N; X+=3){
| ~~~~~~~^~
Anna.cpp:48:33: warning: 'offsety' may be used uninitialized in this function [-Wmaybe-uninitialized]
48 | for (int Y = offsety-3+offsets[k].second; Y<N; Y+=3){
| ~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
192 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |