QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684386#7075. Let's Play Jigsaw Puzzles!xly_tyty#WA 2ms11940kbC++231.1kb2024-10-28 13:03:512024-10-28 13:03:51

Judging History

你现在查看的是最新测评结果

  • [2024-10-28 13:03:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11940kb
  • [2024-10-28 13:03:51]
  • 提交

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;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)a[i][j]=0;
	}
	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(d[id]!=-1)
		{
			tx=x+1,ty=y;
			if(!a[tx][ty])
			{
				a[tx][ty]=d[id];
				q.push({tx,ty,d[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: 2ms
memory: 11940kb

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 '