QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#684360 | #7075. Let's Play Jigsaw Puzzles! | xly_tyty# | WA | 0ms | 11824kb | C++23 | 1.3kb | 2024-10-28 12:52:22 | 2024-10-28 12:52:22 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const long long N=1e6+10,mod=998244353,INF=1e15;
ll n,m,k,d[N],u[N],l[N],r[N];
bool st[N];
int a[1010][1010];
struct node
{
int x,y,id;
};
void solve()
{
cin>>n;
int idx=-1;
for(int i=1;i<=n*n;i++)
{
cin>>u[i]>>d[i]>>l[i]>>r[i];
if(u[i]==-1&&l[i]==-1)
{
idx=i;
}
}
a[1][1]=idx;
queue<node>q;
q.push({1,1,idx});
while(q.size())
{
auto t=q.front();q.pop();
int x=t.x,y=t.y,id=t.id;
int tx,ty;
/*if(u[id]!=-1)
{
tx=x-1,ty=y;
if(!a[tx][ty])
{
a[tx][ty]=u[id];
q.push({tx,ty,u[id]});
}
}*/
if(d[id]!=-1)
{
tx=x+1,ty=y;
if(!a[tx][ty])
{
a[tx][ty]=d[id];
q.push({tx,ty,d[id]});
}
}
/*if(l[id]!=-1)
{
tx=x,ty=y-1;
if(!a[tx][ty])
{
a[tx][ty]=l[id];
q.push({tx,ty,l[id]});
}
}*/
if(r[id]!=-1)
{
tx=x,ty=y+1;
if(!a[tx][ty])
{
a[tx][ty]=r[id];
q.push({tx,ty,r[id]});
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<a[i][j]<<' ';
}
cout<<endl;
}
}
signed main()
{
cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
int T;T=1;
while(T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11824kb
input:
2 -1 3 -1 2 -1 4 1 -1 1 -1 -1 4 2 -1 3 -1
output:
1 2 3 4
result:
wrong answer 1st lines differ - expected: '1 2', found: '1 2 '