#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int n,k;
int grid[105][105];
const ii coord[]={{-1,-1},{-1,0},{-1,1},
{0,-1},{0,0},{0,1},
{1,-1},{1,0},{1,1}};
} // namespace
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
n=N,k=K;
memset(grid,0,sizeof(grid));
rep(x,0,n) rep(y,0,n){
int num=(x%3)*3+(y%3);
if (num==0) grid[x][y]=14;
else if (num==8) grid[x][y]=1;
else{
num--;
rep(z,0,9) if (x==R[num]+coord[z].fi && y==C[num]+coord[z].se){
grid[x][y]=z+1;
}
if (grid[x][y]==0){
if (C[num]<y-1) grid[x][y]=10;
else if (y+1<C[num]) grid[x][y]=11;
else if (R[num]<x-1) grid[x][y]=12;
else if (x+1<R[num]) grid[x][y]=13;
}
}
}
/*
rep(x,0,n){
rep(y,0,n) cout<<grid[x][y]<<" "; cout<<endl;
}
//*/
rep(x,0,n) rep(y,0,n) SetFlag(x,y,grid[x][y]);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int k;
const ii coord[]={{-1,-1},{-1,0},{-1,1},
{0,-1},{0,0},{0,1},
{1,-1},{1,0},{1,1}};
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
k=K;
int px,py;
rep(x,0,9) if (value[x]==14){
px=x/3,py=x%3;
}
vector<int> ans;
rep(x,0,k){
int dx=(px+(x+1)/3)%3;
int dy=(py+(x+1))%3;
int i=dx*3+dy;
if (value[i]<=9){
int ddx=(dx-1)-coord[value[i]-1].fi;
int ddy=(dy-1)-coord[value[i]-1].se;
//cout<<x<<" "<<ddx<<" "<<ddy<<endl;
if (ddy>0) ans.pub(0);
else if (ddy<0) ans.pub(1);
else if (ddx>0) ans.pub(2);
else if (ddx<0) ans.pub(3);
else ans.pub(4);
}
else if (value[i]==10) ans.pub(1);
else if (value[i]==11) ans.pub(0);
else if (value[i]==12) ans.pub(3);
else if (value[i]==13) ans.pub(2);
}
for (auto &it:ans) cout<<it<<" "; cout<<endl;
return ans;
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:64:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
64 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~
Bruno.cpp:64:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
64 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~~
Bruno.cpp:42:13: warning: 'py' may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | int dy=(py+(x+1))%3;
| ~~~^~~~~~~
Bruno.cpp:41:13: warning: 'px' may be used uninitialized in this function [-Wmaybe-uninitialized]
41 | int dx=(px+(x+1)/3)%3;
| ~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |