QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#301998 | #529. Camel | xztmax67 | 25 | 39ms | 7540kb | C++14 | 2.5kb | 2024-01-10 15:12:19 | 2024-01-10 15:12:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
const int mx[8][5][5]=
{
{{ 1, 9,19, 2,10,},
{14,22, 5,13,21,},
{ 7,17,25, 8,18,},
{ 4,12,20, 3,11,},
{15,23, 6,16,24,}},//0 从 (1,1) 开始,从 (3,3) 结束
{{ 1,12, 5, 2,13,},
{ 7,18,15,10,19,},
{23, 3,25,22, 4,},
{16,11, 6,17,14,},
{ 8,21,24, 9,20,}},//1 从 (1,1) 开始,从 (5,3) 出发,从 (3,3) 进来
{{ 1, 8,16, 2, 7,},
{11,19, 5,10,18,},
{22,14,25,21,15,},
{ 4, 9,17, 3, 6,},
{12,20,23,13,24,}},//2 从 (1,1) 开始,从 (5,3) 出发,从 (5,5) 进来到 (5,3)
{{22,16,10,21,15,},
{ 3,25,13,18, 5,},
{ 9,20, 1, 8,11,},
{23,17, 4,24,14,},
{ 2, 7,12,19, 6,}},//3 从 (3,3) 开始,向 (2,2) 走
{{ 9,22,25,10,21,},
{17,12, 7,18,15,},
{24, 4, 1,23, 5,},
{ 8,19,16,11,20,},
{ 2,13, 6, 3,14,}},//4 从 (3,3) 开始,向上走
{{16,11, 6,17,12,},
{ 8,19,14, 9,20,},
{24, 4, 1,23, 5,},
{15,10, 7,18,13,},
{ 2,22,25, 3,21,}},//5 从 (3,3) 开始,向下走
{{ 9,17,24,10,18,},
{22,12, 7,21,13,},
{25, 4, 1,16, 5,},
{ 8,20,23,11,19,},
{ 2,15, 6, 3,14,}},//6 从 (3,3) 开始,向左走
{{ 6,19,24, 5,18,},
{22, 9,16,21,10,},
{14, 4, 1,13,25,},
{ 7,20,23, 8,17,},
{ 2,12,15, 3,11,}}//7 从 (3,3) 开始,向右走
};
int n;
int ans[N][N];
int cnt;
void push(int stx,int sty,int id)
{
stx=(stx-1)*5+1,sty=(sty-1)*5+1;
for(int i=0;i<5;i++)for(int j=0;j<5;j++)ans[stx+i][sty+j]=cnt+mx[id][i][j];
cnt+=(id==1?24:id==2?23:25);
}
//0 5*5
//1 偶数起点
//2 奇数起点
//3 奇数终点转折
//4 向上
//5 向下
//6 向左
//7 向右
signed main()
{
// freopen("w.out","w",stdout);
scanf("%d",&n);int m=n/5;
if(n==5)push(1,1,0);
else if(m%2==0)
{
push(1,1,1);for(int i=2;i<m;i++)push(i,1,5);push(m,1,7);
for(int i=m;i>=1;i-=2)
{
for(int j=2;j<m;j++)push(i,j,7);push(i,m,4);
for(int j=m-1;j>2;j--)push(i-1,j,6);
if(i>2)push(i-1,2,4);else push(i-1,2,6);
}
ans[3][3]=++cnt;
}
else
{
push(1,1,2);for(int i=2;i<m;i++)push(i,1,5);push(m,1,7);
for(int i=m;i>1;i-=2)
{
for(int j=2;j<m;j++)push(i,j,7);push(i,m,4);
if(i>3)
{
for(int j=m-1;j>2;j--)push(i-1,j,6);
push(i-1,2,4);
}
else
{
for(int j=m;j>1;j-=2)
{
push(2,j,4);push(1,j,6);
push(1,j-1,5);
if(j==3)push(2,j-1,3);else push(2,j-1,6);
}
}
}
ans[5][5]=++cnt,ans[3][3]=++cnt;
}
for(int i=1;i<=n;i++,puts(""))
for(int j=1;j<=n;j++)printf("%d ",ans[i][j]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 20
Accepted
time: 1ms
memory: 3896kb
input:
5
output:
1 9 19 2 10 14 22 5 13 21 7 17 25 8 18 4 12 20 3 11 15 23 6 16 24
result:
ok
Test #2:
score: 5
Accepted
time: 0ms
memory: 3712kb
input:
15
output:
1 8 16 2 7 189 184 179 190 185 157 165 172 158 166 11 19 5 10 18 181 192 187 182 193 170 160 155 169 161 22 14 225 21 15 197 177 174 196 178 173 152 149 164 153 4 9 17 3 6 188 183 180 191 186 156 168 171 159 167 12 20 23 13 224 175 195 198 176 194 150 163 154 151 162 39 34 29 40 35 220 214 208 ...
result:
ok
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3776kb
input:
20
output:
1 12 5 2 13 333 341 348 334 342 308 316 323 309 317 0 0 0 0 0 7 18 15 10 19 346 336 331 345 337 321 311 306 320 312 0 0 0 0 0 23 3 350 22 4 349 328 325 340 329 324 303 300 315 304 0 0 0 0 0 16 11 6 17 14 332 344 347 335 343 307 319 322 310 318 0 0 0 0 0 8 21 24 9 20 326 339 330 327 338 301 314 3...
result:
wrong answer Integer 0 violates the range [1, 400]
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3696kb
input:
25
output:
1 8 16 2 7 564 559 554 565 560 532 540 547 533 541 464 459 454 465 460 432 440 447 433 441 11 19 5 10 18 556 567 562 557 568 545 535 530 544 536 456 467 462 457 468 445 435 430 444 436 22 14 600 21 15 572 552 549 571 553 548 527 524 539 528 472 452 449 471 453 448 427 424 439 428 4 9 17 3 6 563 5...
result:
wrong answer Integer 0 violates the range [1, 625]
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3864kb
input:
55
output:
1 8 16 2 7 2889 2884 2879 2890 2885 2857 2865 2872 2858 2866 2789 2784 2779 2790 2785 2757 2765 2772 2758 2766 2689 2684 2679 2690 2685 2657 2665 2672 2658 2666 2589 2584 2579 2590 2585 2557 2565 2572 2558 2566 2489 2484 2479 2490 2485 2457 2465 2472 2458 2466 11 19 5 10 18 2881 2892 2887 2882 2893...
result:
wrong answer Integer 0 violates the range [1, 3025]
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 4216kb
input:
90
output:
1 12 5 2 13 7858 7866 7873 7859 7867 7833 7841 7848 7834 7842 7808 7816 7823 7809 7817 7783 7791 7798 7784 7792 7758 7766 7773 7759 7767 7733 7741 7748 7734 7742 7708 7716 7723 7709 7717 7683 7691 7698 7684 7692 7658 7666 7673 7659 7667 7633 7641 7648 7634 7642 7608 7616 7623 7609 7617 7583 7591 759...
result:
wrong answer Integer 0 violates the range [1, 8100]
Test #7:
score: 0
Wrong Answer
time: 2ms
memory: 4260kb
input:
135
output:
1 8 16 2 7 17889 17884 17879 17890 17885 17857 17865 17872 17858 17866 17789 17784 17779 17790 17785 17757 17765 17772 17758 17766 17689 17684 17679 17690 17685 17657 17665 17672 17658 17666 17589 17584 17579 17590 17585 17557 17565 17572 17558 17566 17489 17484 17479 17490 17485 17457 17465 17472 1...
result:
wrong answer Integer 0 violates the range [1, 18225]
Test #8:
score: 0
Wrong Answer
time: 3ms
memory: 4440kb
input:
200
output:
1 12 5 2 13 39483 39491 39498 39484 39492 39458 39466 39473 39459 39467 39433 39441 39448 39434 39442 39408 39416 39423 39409 39417 39383 39391 39398 39384 39392 39358 39366 39373 39359 39367 39333 39341 39348 39334 39342 39308 39316 39323 39309 39317 39283 39291 39298 39284 39292 39258 39266 39273 ...
result:
wrong answer Integer 0 violates the range [1, 40000]
Test #9:
score: 0
Wrong Answer
time: 5ms
memory: 4840kb
input:
315
output:
1 8 16 2 7 98439 98434 98429 98440 98435 98407 98415 98422 98408 98416 98339 98334 98329 98340 98335 98307 98315 98322 98308 98316 98239 98234 98229 98240 98235 98207 98215 98222 98208 98216 98139 98134 98129 98140 98135 98107 98115 98122 98108 98116 98039 98034 98029 98040 98035 98007 98015 98022 9...
result:
wrong answer Integer 0 violates the range [1, 99225]
Test #10:
score: 0
Wrong Answer
time: 9ms
memory: 5160kb
input:
400
output:
1 12 5 2 13 158983 158991 158998 158984 158992 158958 158966 158973 158959 158967 158933 158941 158948 158934 158942 158908 158916 158923 158909 158917 158883 158891 158898 158884 158892 158858 158866 158873 158859 158867 158833 158841 158848 158834 158842 158808 158816 158823 158809 158817 158783 1...
result:
wrong answer Integer 0 violates the range [1, 160000]
Test #11:
score: 0
Wrong Answer
time: 13ms
memory: 5596kb
input:
495
output:
1 8 16 2 7 243789 243784 243779 243790 243785 243757 243765 243772 243758 243766 243689 243684 243679 243690 243685 243657 243665 243672 243658 243666 243589 243584 243579 243590 243585 243557 243565 243572 243558 243566 243489 243484 243479 243490 243485 243457 243465 243472 243458 243466 243389 24...
result:
wrong answer Integer 0 violates the range [1, 245025]
Test #12:
score: 0
Wrong Answer
time: 11ms
memory: 5872kb
input:
550
output:
1 12 5 2 13 301108 301116 301123 301109 301117 301083 301091 301098 301084 301092 301058 301066 301073 301059 301067 301033 301041 301048 301034 301042 301008 301016 301023 301009 301017 300983 300991 300998 300984 300992 300958 300966 300973 300959 300967 300933 300941 300948 300934 300942 300908 3...
result:
wrong answer Integer 0 violates the range [1, 302500]
Test #13:
score: 0
Wrong Answer
time: 21ms
memory: 6688kb
input:
710
output:
1 12 5 2 13 502308 502316 502323 502309 502317 502283 502291 502298 502284 502292 502258 502266 502273 502259 502267 502233 502241 502248 502234 502242 502208 502216 502223 502209 502217 502183 502191 502198 502184 502192 502158 502166 502173 502159 502167 502133 502141 502148 502134 502142 502108 5...
result:
wrong answer Integer 0 violates the range [1, 504100]
Test #14:
score: 0
Wrong Answer
time: 33ms
memory: 6956kb
input:
825
output:
1 8 16 2 7 678564 678559 678554 678565 678560 678532 678540 678547 678533 678541 678464 678459 678454 678465 678460 678432 678440 678447 678433 678441 678364 678359 678354 678365 678360 678332 678340 678347 678333 678341 678264 678259 678254 678265 678260 678232 678240 678247 678233 678241 678164 67...
result:
wrong answer Integer 0 violates the range [1, 680625]
Test #15:
score: 0
Wrong Answer
time: 39ms
memory: 7192kb
input:
880
output:
1 12 5 2 13 772183 772191 772198 772184 772192 772158 772166 772173 772159 772167 772133 772141 772148 772134 772142 772108 772116 772123 772109 772117 772083 772091 772098 772084 772092 772058 772066 772073 772059 772067 772033 772041 772048 772034 772042 772008 772016 772023 772009 772017 771983 7...
result:
wrong answer Integer 0 violates the range [1, 774400]
Test #16:
score: 0
Wrong Answer
time: 31ms
memory: 7292kb
input:
925
output:
1 8 16 2 7 853314 853309 853304 853315 853310 853282 853290 853297 853283 853291 853214 853209 853204 853215 853210 853182 853190 853197 853183 853191 853114 853109 853104 853115 853110 853082 853090 853097 853083 853091 853014 853009 853004 853015 853010 852982 852990 852997 852983 852991 852914 85...
result:
wrong answer Integer 0 violates the range [1, 855625]
Test #17:
score: 0
Wrong Answer
time: 36ms
memory: 7540kb
input:
990
output:
1 12 5 2 13 977608 977616 977623 977609 977617 977583 977591 977598 977584 977592 977558 977566 977573 977559 977567 977533 977541 977548 977534 977542 977508 977516 977523 977509 977517 977483 977491 977498 977484 977492 977458 977466 977473 977459 977467 977433 977441 977448 977434 977442 977408 9...
result:
wrong answer Integer 0 violates the range [1, 980100]