QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#59174 | #2540. Build The Grid | justin_holmes# | WA | 2ms | 3592kb | C++ | 1.1kb | 2022-10-28 14:49:17 | 2022-10-28 14:49:21 |
Judging History
answer
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 200010
using namespace std;
typedef long long ll;
ll read()
{
ll x=0,f=1;
char ch=getchar();
while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n;
char ans[505][505];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main()
{
n=read();
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++) ans[i][j]='W';
int x=1,y=1,dir=0;
int len=n-1,op=0,now=0;
while(len>1)
{
ans[x][y]='B';now++;
if(now==len)
{
if(op==0)
{
op=1;
now=1;
dir=(dir+1)%4;
}
else{
now=1;
dir=(dir+1)%4;
len--;
}
}
x+=dx[dir];y+=dy[dir];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
printf("%c",ans[i][j]);
}
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3592kb
input:
3
output:
BWW BBW WWW
result:
ok accepted
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3560kb
input:
2
output:
WW WW
result:
wrong answer P is not a permutation