QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666031 | #7075. Let's Play Jigsaw Puzzles! | wsyjpgs | WA | 0ms | 3584kb | C++14 | 2.3kb | 2024-10-22 16:20:53 | 2024-10-22 16:21:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int a[1005][1005];
struct pp
{
long long s,x,z,y;
}num[10005];
int find(int n,int x)//1e3
{
for(int i=1;i<=n;i++)
{
//cout<<num[i].z<<" $$";
if(num[i].z==x)
{
return i;
}
}
return -1;
}
int find2(int n,int x,map<int,pp>& my)
{
for(int i=1;i<=n;i++)
{
if(my.find(num[i].z)==my.end())
{
return i;
}
}
return -1;
}
int main()
{
int n;
cin>>n;
a[1][1]=1;
int s,x,z,y,k=1;
map<int,pp> ms,mx,mz,my;
for(int i=1;i<=n*n;i++)
{
cin>>s>>x>>z>>y;
if(s==-1)
{
num[k++]={s,x,z,y};
//cout<<"num["<<k-1<<"]:"<<s<<" "<<x<<" "<<z<<" "<<y<<endl;
}
ms[s]={s,x,z,y};
mx[x]={s,x,z,y};
mz[z]={s,x,z,y};
my[y]={s,x,z,y};
}
int xz=-1,pos;
for(int i=1;i<=n;i+=2)//1e3
{
//cout<<"XZ:"<<xz<<endl;
pos=find(k-1,xz);//1e3
//cout<<"pos:"<<pos<<endl;
//cout<<"num:"<<num[pos].z<<" "<<num[pos].y<<" "<<num[pos].x<<endl;
a[1][i+1]=num[pos].y;
a[1][i-1]=num[pos].z;
a[2][i]=num[pos].x;
//cout<<"a[2][i]"<<a[2][i]<<" i:"<<i<<endl;
xz=num[pos].y;
}
pos=find2(k-1,a[1][1],my);
//cout<<"num2:"<<num[pos].z<<" "<<num[pos].y<<" "<<num[pos].x<<endl;;
a[1][1]=num[pos].z;
a[1][3]=num[pos].y;
a[2][2]=num[pos].x;
//cout<<a[1][2]<<"$$"<<endl;
//xz=a[1][2];
xz=a[1][1];
for(int i=2;i<=n;i+=2)//1e3
{
//cout<<"XZ:"<<xz<<endl;
pos=find(k-1,xz);//1e3
//cout<<"pos:"<<pos<<endl;
//cout<<"num:"<<num[pos].z<<" "<<num[pos].y<<" "<<num[pos].x<<endl;
a[1][i+1]=num[pos].y;
a[1][i-1]=num[pos].z;
a[2][i]=num[pos].x;
//cout<<"a[2][i]"<<a[2][i]<<" i:"<<i<<endl;
xz=num[pos].y;
}
// cout<<a[2][3]<<endl;
pp posp;
for(int i=1;i<n;i++)
{
for(int j=1;j<=n;j++)
{
posp=ms[a[i][j]];
//cout<<"posx"<<posp.s<<" ";
a[i+2][j]=posp.x;
}
//cout<<endl;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
//3
//-1 2 -1 1
//-1 4 3 5
//-1 6 1 -1
//3 7 -1 4
//1 8 2 6
//5 9 4 -1
//2 -1 -1 8
//4 -1 7 9
//6 -1 8 -1
//3 1 5
//2 4 6
//7 8 9
//4
//-1 5 -1 4
//-1 7 1 3
//-1 9 4 2
//-1 8 3 -1
//1 11 -1 7
//4 13 5 9
//3 12 7 8
//2 14 9 -1
//5 16 -1 11
//7 6 11 12
//9 10 13 14
//8 15 12 -1
//11 -1 -1 6
//13 -1 16 10
//12 -1 6 15
//14 -1 10 -1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
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 '