QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#93787 | #6189. Full Clue Problem | Liberty12619 | AC ✓ | 2ms | 3568kb | C++20 | 1.1kb | 2023-04-02 14:20:05 | 2023-04-02 14:20:09 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 30;
int a[N][N],ans1[N][N],ans2[N][N];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
void solve()
{
int n;
cin>>n;
int x=1,y=n,t=0;
ans1[x][y]=ans2[x][y]=1;
while(true)
{
if(x==n&&y==1) break;
if(t&1)
{
ans1[x+1][y]=ans1[x+1][y-1]=1;
ans2[x][y-1]=ans2[x+1][y-1]=1;
}
else
{
ans2[x+1][y]=ans2[x+1][y-1]=1;
ans1[x][y-1]=ans1[x+1][y-1]=1;
}
t++;
x++,y--;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
int res=0;
for(int k=0;k<4;k++)
{
int ix = i+dx[k],iy = j+dy[k];
if(ix<1||ix>n||iy<1||iy>n) continue;
if(ans1[ix][iy]) res++;
}
if(ans1[i][j]) a[i][j]=4-res;
else a[i][j]=res;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) cout<<a[i][j]<<" ";
puts("");
}
puts("");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) cout<<ans1[i][j]<<" ";
puts("");
}
puts("");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) cout<<ans2[i][j]<<" ";
puts("");
}
puts("");
}
signed main()
{
int T=1;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3524kb
input:
5
output:
0 0 1 2 3 0 1 2 2 2 1 2 2 2 1 2 2 2 1 0 3 2 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0
result:
ok ok
Test #2:
score: 0
Accepted
time: 2ms
memory: 3304kb
input:
2
output:
2 3 3 2 1 1 1 0 0 1 1 1
result:
ok ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 3424kb
input:
3
output:
1 2 3 2 2 2 3 2 1 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 1 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
4
output:
0 1 2 3 1 2 2 2 2 2 2 1 3 2 1 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 0 0 0 0 0 1 0 1 1 1 0 1 0 0 1 1 0 0
result:
ok ok
Test #5:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
10
output:
0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 1 2 2 2 0 0 0 0 0 1 2 2 2 1 0 0 0 0 1 2 2 2 1 0 0 0 0 1 2 2 2 1 0 0 0 0 1 2 2 2 1 0 0 0 0 1 2 2 2 1 0 0 0 0 1 2 2 2 1 0 0 0 0 0 2 2 2 1 0 0 0 0 0 0 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0...
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
19
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1...
result:
ok ok
Test #7:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
20
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0...
result:
ok ok