QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263666 | #7740. Puzzle: Question Mark | ucup-team987# | AC ✓ | 222ms | 19284kb | C++20 | 4.3kb | 2023-11-25 01:51:46 | 2023-11-25 01:51:47 |
Judging History
answer
#include<iostream>
#include<cassert>
using namespace std;
int N,idx;
int A[2000][2000];
void add(int x,int y)
{
assert(0<=x&&x<N);
assert(0<=y&&y<N);
assert(A[x][y]==0);
assert(idx>=1);
A[x][y]=idx;
}
void place(int x,int y,int t)
{
idx++;
if(t==0)
{
add(x,y);
add(x,y+1);
add(x+1,y+1);
add(x+2,y);
}
else if(t==1)
{
add(x,y);
add(x+1,y+1);
add(x,y+2);
add(x+1,y+2);
}
else if(t==2)
{
add(x,y+1);
add(x+1,y);
add(x+2,y);
add(x+2,y+1);
}
else if(t==3)
{
add(x,y);
add(x,y+1);
add(x+1,y);
add(x+1,y+2);
}
else if(t==4)
{
add(x,y);
add(x,y+1);
add(x+1,y);
add(x+2,y+1);
}
else if(t==5)
{
add(x,y+1);
add(x,y+2);
add(x+1,y);
add(x+1,y+2);
}
else if(t==6)
{
add(x,y);
add(x+1,y+1);
add(x+2,y);
add(x+2,y+1);
}
else if(t==7)
{
add(x,y);
add(x,y+2);
add(x+1,y);
add(x+1,y+1);
}
else assert(false);
}
void solve()
{
if(N%4==0)
{
for(int i=0;i<N;i+=4)
{
for(int j=0;j<N;j+=2)
{
place(i,j,0);
place(i+1,j,6);
}
}
}
else if(N%4==2)
{
N-=2;
solve();
N+=2;
for(int i=0;i<N-2;i+=4)
{
place(i,N-2,0);
place(i+1,N-2,6);
place(N-2,i,3);
place(N-2,i+1,5);
}
}
else if(N%4==3)
{
N-=2;
solve();
N+=2;
for(int i=0;i<N-3;i+=4)
{
place(i,N-2,0);
place(i+1,N-2,6);
place(N-2,i,3);
place(N-2,i+1,5);
}
place(N-3,N-2,0);
place(N-2,N-3,3);
}
else
{
assert(N%4==1);
if(N==1);
else if(N==5)
{
place(0,0,0);
place(1,0,6);
place(0,2,7);
place(0,3,6);
place(3,2,1);
}
else if(N==9)
{
place(7,4,3);
place(7,1,1);
place(7,0,7);
place(6,7,6);
place(6,5,0);
place(5,7,0);
place(5,0,1);
place(4,3,6);
place(4,0,0);
place(3,5,6);
place(3,2,4);
place(2,7,6);
place(2,6,7);
place(2,4,4);
place(1,0,6);
place(0,6,1);
place(0,5,7);
place(0,2,1);
place(0,2,2);
place(0,0,0);
}
else if(N==13)
{
place(0,0,0);
place(1,0,6);
place(0,2,0);
place(1,2,6);
place(11,6,1);
place(11,5,7);
place(11,0,1);
place(10,11,6);
place(10,9,6);
place(10,3,6);
place(10,0,0);
place(9,11,0);
place(9,9,0);
place(9,6,3);
place(9,2,4);
place(8,7,0);
place(8,4,6);
place(8,0,7);
place(7,3,4);
place(6,11,6);
place(6,9,6);
place(6,8,7);
place(6,5,1);
place(6,5,2);
place(6,0,4);
place(5,11,0);
place(5,1,6);
place(4,6,1);
place(4,3,1);
place(4,3,2);
place(3,9,6);
place(3,6,0);
place(2,11,6);
place(2,10,7);
place(2,8,4);
place(1,4,6);
place(0,10,1);
place(0,9,7);
place(0,6,1);
place(0,6,2);
place(0,4,0);
place(4,0,3);
}
else
{
assert(N>=17);
N-=8;
solve();
N+=8;
place(9+N-11,8+N-11,3);
place(9+N-11,5+N-11,1);
place(9+N-11,4+N-11,7);
place(9+N-11,1+N-11,1);
place(9+N-11,0+N-11,7);
place(8+N-11,9+N-11,0);
place(7+N-11,6+N-11,1);
place(7+N-11,3+N-11,3);
place(7+N-11,0+N-11,1);
place(6+N-11,6+N-11,0);
place(6+N-11,4+N-11,0);
place(6+N-11,0+N-11,0);
place(5+N-11,9+N-11,6);
place(5+N-11,8+N-11,7);
place(5+N-11,2+N-11,7);
place(4+N-11,6+N-11,7);
place(4+N-11,3+N-11,3);
place(3+N-11,8+N-11,1);
place(3+N-11,5+N-11,3);
place(3+N-11,0+N-11,1);
place(3+N-11,0+N-11,2);
place(2+N-11,7+N-11,3);
place(1+N-11,3+N-11,6);
place(0+N-11,9+N-11,6);
place(0+N-11,8+N-11,7);
place(0+N-11,5+N-11,1);
place(0+N-11,5+N-11,2);
place(0+N-11,3+N-11,0);
for(int i=0;i<N-11;i+=2)
{
place(i,N-8,3);
place(i,N-7,5);
place(i,N-4,3);
place(i,N-3,5);
place(N-8,i,0);
place(N-7,i,6);
place(N-4,i,0);
place(N-3,i,6);
}
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
cin>>N;
for(int i=0;i<N;i++)for(int j=0;j<N;j++)A[i][j]=0;
idx=0;
solve();
int cnt=0;
for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(A[i][j]!=0)cnt++;
assert(cnt%4==0);
cnt/=4;
if(N%2==1&&N>=9)
{
assert(N*N/4==cnt);
}
cout<<cnt<<"\n";
for(int i=0;i<N;i++)for(int j=0;j<N;j++)cout<<A[i][j]<<(j+1==N?"\n":" ");
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
2 3 4
output:
2 0 1 1 2 2 1 2 1 2 4 1 1 3 3 2 1 4 3 1 2 3 4 2 2 4 4
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 201ms
memory: 4876kb
input:
246 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
output:
0 0 0 0 0 0 0 2 0 1 1 2 2 1 2 1 2 4 1 1 3 3 2 1 4 3 1 2 3 4 2 2 4 4 5 1 1 3 4 3 2 1 3 3 4 1 2 0 4 4 2 2 5 0 5 0 0 0 5 5 8 1 1 3 3 5 5 2 1 4 3 6 5 1 2 3 4 5 6 2 2 4 4 6 6 7 7 8 8 0 0 7 8 7 8 0 0 11 1 1 3 4 3 6 6 2 1 3 3 4 7 6 1 2 0 4 4 6 7 2 2 5 0 5 7 7 0 0 0 5 5 10 10 8 8 9 9 11 11 10 8 9 8 9 11 10 ...
result:
ok Correct. (246 test cases)
Test #3:
score: 0
Accepted
time: 199ms
memory: 6980kb
input:
64 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
output:
15252 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 151...
result:
ok Correct. (64 test cases)
Test #4:
score: 0
Accepted
time: 217ms
memory: 6352kb
input:
45 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
output:
24180 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 151...
result:
ok Correct. (45 test cases)
Test #5:
score: 0
Accepted
time: 204ms
memory: 8204kb
input:
35 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
output:
31684 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101 ...
result:
ok Correct. (35 test cases)
Test #6:
score: 0
Accepted
time: 188ms
memory: 8220kb
input:
30 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
output:
38220 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 151...
result:
ok Correct. (30 test cases)
Test #7:
score: 0
Accepted
time: 221ms
memory: 19180kb
input:
2 2000 1000
output:
1000000 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 10...
result:
ok Correct. (2 test cases)
Test #8:
score: 0
Accepted
time: 222ms
memory: 19284kb
input:
2 1999 999
output:
999000 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 15...
result:
ok Correct. (2 test cases)
Test #9:
score: 0
Accepted
time: 219ms
memory: 19268kb
input:
2 1998 998
output:
998000 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...
result:
ok Correct. (2 test cases)
Test #10:
score: 0
Accepted
time: 216ms
memory: 19272kb
input:
2 1997 997
output:
997002 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 15...
result:
ok Correct. (2 test cases)
Test #11:
score: 0
Accepted
time: 220ms
memory: 19248kb
input:
2 1996 996
output:
996004 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...
result:
ok Correct. (2 test cases)
Test #12:
score: 0
Accepted
time: 218ms
memory: 19160kb
input:
2 1995 995
output:
995006 20 20 18 19 18 17 16 17 16 49 49 50 50 51 51 52 52 101 101 102 102 103 103 104 104 185 185 186 186 187 187 188 188 301 301 302 302 303 303 304 304 449 449 450 450 451 451 452 452 629 629 630 630 631 631 632 632 841 841 842 842 843 843 844 844 1085 1085 1086 1086 1087 1087 1088 1088 1361 1361 ...
result:
ok Correct. (2 test cases)
Test #13:
score: 0
Accepted
time: 210ms
memory: 19216kb
input:
2 1994 994
output:
994008 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...
result:
ok Correct. (2 test cases)
Test #14:
score: 0
Accepted
time: 209ms
memory: 19144kb
input:
2 1993 993
output:
993012 20 20 18 19 18 17 16 17 16 49 49 50 50 51 51 52 52 101 101 102 102 103 103 104 104 185 185 186 186 187 187 188 188 301 301 302 302 303 303 304 304 449 449 450 450 451 451 452 452 629 629 630 630 631 631 632 632 841 841 842 842 843 843 844 844 1085 1085 1086 1086 1087 1087 1088 1088 1361 1361 ...
result:
ok Correct. (2 test cases)
Test #15:
score: 0
Accepted
time: 213ms
memory: 19200kb
input:
2 1992 992
output:
992016 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...
result:
ok Correct. (2 test cases)
Test #16:
score: 0
Accepted
time: 210ms
memory: 19196kb
input:
2 1991 991
output:
991020 1 1 3 3 41 41 39 40 39 38 37 38 37 71 71 72 72 73 73 74 74 139 139 140 140 141 141 142 142 239 239 240 240 241 241 242 242 371 371 372 372 373 373 374 374 535 535 536 536 537 537 538 538 731 731 732 732 733 733 734 734 959 959 960 960 961 961 962 962 1219 1219 1220 1220 1221 1221 1222 1222 15...
result:
ok Correct. (2 test cases)
Extra Test:
score: 0
Extra Test Passed