#include <bits/stdc++.h>
#include "Anna.h"
/*
Code for each with one of 7 cells in each 3x3 grid -> 75 points
The cell
A
123
B 456 D
789
C
*/
void Anna(int N, int K, std::vector<int> R, std::vector<int> C){
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
int curloc=(i%3)*3+j%3;
if(curloc==7){
SetFlag(i,j,14);
}else if(curloc<7){
if(R[curloc]<i-1){
SetFlag(i,j,10);
}else if(R[curloc]>i+1){
SetFlag(i,j,12);
}else if(C[curloc]<j-1){
SetFlag(i,j,11);
}else if(C[curloc]>j+1){
SetFlag(i,j,13);
}else{
int crpos=(R[curloc]-i+1)*3+(C[curloc]-j+1)+1;
SetFlag(i,j,crpos);
}
}else{
SetFlag(i,j,1);
}
}
}
}
#include <bits/stdc++.h>
#include "Bruno.h"
/*
Code for each with one of 7 cells in each 3x3 grid -> 75 points
The cell
A
123
B 456 D
789
C
*/
std::vector<int> Bruno(int K, std::vector<int> value){
std::vector<int> moves;
for(int cn=0;cn<K;cn++){
int result;
int curmpx,curmpy;
for(int i=0;i<9;i++){
if(value[i]==14){
curmpx=i%3-1;
curmpy=i/3-2;
}
}
int curoffx=((curmpx+(cn%3-1)+12)%3+1)%3-1;
int curoffy=((curmpx+(cn/3-1)+12)%3+1)%3-1;
int curind=(curoffx+1)+(curoffy+1)*3;
int curval=value[curind];
if(curval==10){
result=3;
}else if(curval==11){
result=1;
}else if(curval==12){
result=2;
}else if(curval==13){
result=0;
}else{
int targx=curoffx+((curval-1)%3-1);
int targy=curoffy+((curval-1)/3-1);
if(targx<0){
result=1;
}else if(targx>0){
result=0;
}else if(targy<0){
result=3;
}else if(targy>0){
result=2;
}else{
result=4;
}
}
moves.push_back(result);
}
return moves;
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:18:20: warning: variable 'curmpy' set but not used [-Wunused-but-set-variable]
18 | int curmpx,curmpy;
| ^~~~~~
Bruno.cpp:26:29: warning: 'curmpx' may be used uninitialized in this function [-Wmaybe-uninitialized]
26 | int curoffy=((curmpx+(cn/3-1)+12)%3+1)%3-1;
| ~~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |