QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666042 | #7075. Let's Play Jigsaw Puzzles! | wsyjpgs | TL | 2071ms | 111000kb | C++14 | 2.4kb | 2024-10-22 16:24:05 | 2024-10-22 16:24:11 |
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;
}
if(n==1)
{
a[1][1]=1;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(j!=n)
cout<<a[i][j]<<" ";
else
cout<<a[i][j]<<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
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
2 -1 3 -1 2 -1 4 1 -1 1 -1 -1 4 2 -1 3 -1
output:
1 2 3 4
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 3ms
memory: 4316kb
input:
42 1244 1713 1584 265 1100 1445 250 397 108 1161 26 940 1084 1119 1579 576 485 176 1251 781 917 1361 883 209 568 1162 44 368 1614 914 378 604 1059 687 1373 988 537 911 559 1649 1155 1685 352 1724 434 863 1367 298 963 41 1261 288 601 590 1554 1281 1714 -1 608 979 83 199 1072 1075 984 1411 1592 293 10...
output:
1559 1618 550 492 198 145 1622 466 443 646 676 1428 1586 1569 287 76 1144 445 184 760 1038 888 96 722 24 1683 1096 867 619 1632 683 58 290 512 422 1489 621 1736 1478 1221 1507 1316 878 1142 194 1504 344 1278 1065 615 1582 321 1486 1000 295 1481 916 1198 1274 596 1617 307 110 706 860 708 499 1077 109...
result:
ok 42 lines
Test #3:
score: 0
Accepted
time: 229ms
memory: 26508kb
input:
256 59514 55419 18661 2338 18386 44586 37892 7259 45565 43343 44074 39100 8065 51340 31460 61704 1973 54946 26716 14567 8587 43850 10746 46526 1524 55529 62814 1688 13757 56306 9426 55901 52993 2600 16483 10803 35724 11123 64064 24411 58936 6877 50578 15423 36123 3907 25662 1943 17529 53198 11065 21...
output:
50480 9217 42060 41140 1637 44728 17637 13364 58165 13517 9342 52869 4960 43953 3003 32969 30463 21433 10454 22904 26709 44841 19606 4884 23773 30214 51867 44107 47603 10352 58401 13531 39883 58086 34112 32340 64041 62812 11430 32759 31018 61827 37348 36242 30647 49901 62107 62704 30535 21688 5267 5...
result:
ok 256 lines
Test #4:
score: 0
Accepted
time: 83ms
memory: 15692kb
input:
191 23698 13626 29860 31441 7887 24322 34398 30334 11126 35201 21463 958 11392 30085 2647 17939 28938 2441 9857 732 33598 19941 3810 35849 27476 2838 27327 4183 1072 7423 18633 35342 36174 7868 7824 34627 14627 35047 671 29078 14845 8627 34672 17120 29124 19299 2929 33330 25356 22909 24770 22061 351...
output:
14987 20493 24634 25555 3621 103 7738 10062 15034 34212 17303 19790 12234 35418 2983 28113 26044 24472 11934 9247 25461 19014 9230 8266 10741 14643 19760 17655 17595 3454 19156 35614 28261 7869 35817 16214 9608 17594 12560 31440 22235 13425 7754 11642 21401 19487 11021 15764 2000 10331 15690 24223 2...
result:
ok 191 lines
Test #5:
score: 0
Accepted
time: 1900ms
memory: 103960kb
input:
560 72203 45646 225940 84151 23200 172085 305583 148143 19187 69173 143589 115564 10858 272743 64736 305667 76731 109218 36271 20228 303160 153369 162399 44342 85997 286778 9068 169298 86396 3406 105702 124146 158790 67651 148462 224096 306846 283559 301008 245648 55166 280599 304349 281527 82496 37...
output:
224085 119845 175900 201588 239827 183008 38816 234619 5180 130373 152981 295026 134643 155470 129314 225584 99128 104274 127134 111432 183770 250071 150446 86140 82150 121370 84715 167547 10762 85146 167252 95468 153081 262541 170310 224538 133353 97274 237601 103188 67954 67257 42180 147675 193298...
result:
ok 560 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 4344kb
input:
43 1185 1849 -1 430 1682 257 899 946 1163 1530 1592 317 1678 1744 1463 1334 1592 1580 1464 1530 462 -1 571 1608 699 607 639 519 584 744 161 -1 586 703 1800 887 77 1736 1598 872 698 1076 297 45 1562 1574 718 50 435 1696 1772 589 1816 1192 258 1042 785 1841 618 1203 1231 509 1771 103 496 1522 709 1337...
output:
1821 551 1252 1073 1302 466 1787 1739 1731 1343 1784 1729 616 1551 1235 367 109 975 963 1168 1660 222 1419 1766 604 1520 754 1562 1314 396 1056 1470 1461 1123 503 577 37 1847 280 131 1637 524 1367 1268 1460 570 1638 764 1720 714 1202 978 1363 254 38 869 1782 1362 333 1839 544 1447 1239 485 1068 540 ...
result:
ok 43 lines
Test #7:
score: 0
Accepted
time: 2071ms
memory: 111000kb
input:
579 90512 102801 93308 48869 331400 137671 34396 297128 117209 179703 168627 319180 117666 17573 303023 98937 31041 309597 25283 176683 286250 29553 328705 303255 299034 163378 231128 283125 275697 18465 309254 325775 138419 203716 193839 182352 324333 6110 5508 25465 45184 109255 248198 166854 1904...
output:
122400 145213 192235 211903 40022 281070 185702 163986 86738 156055 172168 222902 117447 217450 272481 71700 122315 62749 149965 82866 5097 213046 263881 1903 197253 35164 208133 40583 212442 159976 194575 221347 118114 90386 27400 222239 205673 50446 76974 258849 141657 8123 215932 99248 45129 2061...
result:
ok 579 lines
Test #8:
score: 0
Accepted
time: 1314ms
memory: 81016kb
input:
488 110871 18943 90010 131829 213854 36909 92742 61484 74063 178728 207929 66184 163209 180828 93568 84875 164622 130490 163951 132221 182591 15082 136552 152122 215364 23828 55924 50723 150658 199318 72102 231016 62679 71620 48922 109254 75130 118108 51334 180247 67112 34806 84090 148041 175129 158...
output:
231228 106356 70555 187978 7592 23531 63412 222255 147410 232002 58890 34812 85386 115744 4391 34972 130589 93173 56740 203402 39016 107638 154674 32714 12904 85412 233480 17728 41685 34904 185708 225173 145548 57890 83520 56529 228995 84062 84952 99206 141413 80521 19291 229046 93370 38999 46973 14...
result:
ok 488 lines
Test #9:
score: -100
Time Limit Exceeded
input:
1000 169030 118433 902236 978629 84782 72306 11244 989711 960726 25357 932157 864236 224317 160222 176503 202676 991085 45686 945176 923522 216182 224394 214439 917827 63493 105551 942441 77579 133778 937237 22921 141341 235245 208679 99377 137036 175065 220128 84501 81633 18459 934111 36668 32948 9...