Submission #3407859
Source Code Expand
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
scanf("%d",&head);
RI(tail...);
}
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int n,dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
bool vis[M][M], vis2[M][M];
char in[M][M];
int main()
{
while(~scanf("%d",&n)) {
REP(i,1,n) REP(j,1,n) in[i][j] = '.';
MSET(vis, false);
MSET(vis2, false);
/*queue<P> q;
vis2[1][2] = true;
q.push(MP(1,2));
while(!q.empty()) {
int i = q.front().F;
int j = q.front().S;
q.pop();
printf("%d %d\n",i,j);
in[i][j] = 'X';
vis[i][j] = true;
REP(k,0,3) {
int i2 = i+dx[k];
int j2 = j+dy[k];
if (i2>=1 && i2<=n && j2>=1 && j2<=n) vis[i2][j2] = true;
}
// +2, -1
if (i+2<=n && j-1>=1 && !vis2[i+2][j-1]) {
vis2[i+2][j-1] = true;
q.push(MP(i+2, j-1));
}
// +1, +2
if (i+1<=n && j+2<=n && !vis[i+1][j+2]) {
vis2[i+1][j+2] = true;
q.push(MP(i+1, j+2));
}
}*/
REP(i,1,n) {
REP(j,1,n) if ((i%5*2)%5 == j%5) {
in[i][j] = 'X';
vis[i][j] = true;
REP(k,0,3) {
int i2 = i+dx[k];
int j2 = j+dy[k];
if (i2>=1 && i2<=n && j2>=1 && j2<=n) vis[i2][j2] = true;
}
}
}
REP(i,1,n) REP(j,1,n) if(!vis[i][j]) {
in[i][j] = 'X';
vis[i][j] = true;
REP(k,0,3) {
int i2 = i+dx[k];
int j2 = j+dy[k];
if (i2>=1 && i2<=n && j2>=1 && j2<=n) vis[i2][j2] = true;
}
}
REP(i,1,n) {
REP(j,1,n) putchar(in[i][j]);
puts("");
}
}
return 0;
}
Submission Info
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
500 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name |
Status |
Exec Time |
Memory |
| in01.txt |
AC |
15 ms |
4224 KiB |
| in02.txt |
AC |
15 ms |
4224 KiB |
| in03.txt |
AC |
15 ms |
4224 KiB |
| in04.txt |
AC |
15 ms |
4224 KiB |
| in05.txt |
AC |
15 ms |
4224 KiB |
| in06.txt |
AC |
4 ms |
2688 KiB |
| in07.txt |
AC |
3 ms |
2560 KiB |
| in08.txt |
AC |
2 ms |
2432 KiB |
| in09.txt |
AC |
2 ms |
2176 KiB |
| in10.txt |
AC |
2 ms |
2176 KiB |
| in11.txt |
AC |
2 ms |
2176 KiB |
| in12.txt |
AC |
2 ms |
2176 KiB |
| sample_01.txt |
AC |
2 ms |
2176 KiB |
| sample_02.txt |
AC |
2 ms |
2176 KiB |
| sample_03.txt |
AC |
2 ms |
2304 KiB |