QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302001#529. Camelxztmax67100 ✓38ms7540kbC++142.5kb2024-01-10 15:13:362024-01-10 15:13:38

Judging History

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

  • [2024-01-10 15:13:38]
  • 评测
  • 测评结果:100
  • 用时:38ms
  • 内存:7540kb
  • [2024-01-10 15:13:36]
  • 提交

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;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;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;
}

详细

Test #1:

score: 20
Accepted
time: 0ms
memory: 3652kb

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: 3756kb

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: 5
Accepted
time: 0ms
memory: 3672kb

input:

20

output:

1 12 5 2 13 383 391 398 384 392 358 366 373 359 367 333 341 348 334 342 
7 18 15 10 19 396 386 381 395 387 371 361 356 370 362 346 336 331 345 337 
23 3 400 22 4 399 378 375 390 379 374 353 350 365 354 349 328 325 340 329 
16 11 6 17 14 382 394 397 385 393 357 369 372 360 368 332 344 347 335 343 
8 ...

result:

ok 

Test #4:

score: 5
Accepted
time: 0ms
memory: 3800kb

input:

25

output:

1 8 16 2 7 589 584 579 590 585 557 565 572 558 566 489 484 479 490 485 457 465 472 458 466 
11 19 5 10 18 581 592 587 582 593 570 560 555 569 561 481 492 487 482 493 470 460 455 469 461 
22 14 625 21 15 597 577 574 596 578 573 552 549 564 553 497 477 474 496 478 473 452 449 464 453 
4 9 17 3 6 588 5...

result:

ok 

Test #5:

score: 5
Accepted
time: 1ms
memory: 4080kb

input:

55

output:

1 8 16 2 7 2989 2984 2979 2990 2985 2957 2965 2972 2958 2966 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 
11 19 5 10 18 2981 2992 2987 2982 2993...

result:

ok 

Test #6:

score: 5
Accepted
time: 1ms
memory: 3996kb

input:

90

output:

1 12 5 2 13 8083 8091 8098 8084 8092 8058 8066 8073 8059 8067 8033 8041 8048 8034 8042 8008 8016 8023 8009 8017 7983 7991 7998 7984 7992 7958 7966 7973 7959 7967 7933 7941 7948 7934 7942 7908 7916 7923 7909 7917 7883 7891 7898 7884 7892 7858 7866 7873 7859 7867 7833 7841 7848 7834 7842 7808 7816 782...

result:

ok 

Test #7:

score: 5
Accepted
time: 1ms
memory: 4412kb

input:

135

output:

1 8 16 2 7 18189 18184 18179 18190 18185 18157 18165 18172 18158 18166 18089 18084 18079 18090 18085 18057 18065 18072 18058 18066 17989 17984 17979 17990 17985 17957 17965 17972 17958 17966 17889 17884 17879 17890 17885 17857 17865 17872 17858 17866 17789 17784 17779 17790 17785 17757 17765 17772 1...

result:

ok 

Test #8:

score: 5
Accepted
time: 0ms
memory: 4424kb

input:

200

output:

1 12 5 2 13 39983 39991 39998 39984 39992 39958 39966 39973 39959 39967 39933 39941 39948 39934 39942 39908 39916 39923 39909 39917 39883 39891 39898 39884 39892 39858 39866 39873 39859 39867 39833 39841 39848 39834 39842 39808 39816 39823 39809 39817 39783 39791 39798 39784 39792 39758 39766 39773 ...

result:

ok 

Test #9:

score: 5
Accepted
time: 2ms
memory: 4944kb

input:

315

output:

1 8 16 2 7 99189 99184 99179 99190 99185 99157 99165 99172 99158 99166 99089 99084 99079 99090 99085 99057 99065 99072 99058 99066 98989 98984 98979 98990 98985 98957 98965 98972 98958 98966 98889 98884 98879 98890 98885 98857 98865 98872 98858 98866 98789 98784 98779 98790 98785 98757 98765 98772 9...

result:

ok 

Test #10:

score: 5
Accepted
time: 9ms
memory: 5456kb

input:

400

output:

1 12 5 2 13 159983 159991 159998 159984 159992 159958 159966 159973 159959 159967 159933 159941 159948 159934 159942 159908 159916 159923 159909 159917 159883 159891 159898 159884 159892 159858 159866 159873 159859 159867 159833 159841 159848 159834 159842 159808 159816 159823 159809 159817 159783 1...

result:

ok 

Test #11:

score: 5
Accepted
time: 13ms
memory: 5600kb

input:

495

output:

1 8 16 2 7 244989 244984 244979 244990 244985 244957 244965 244972 244958 244966 244889 244884 244879 244890 244885 244857 244865 244872 244858 244866 244789 244784 244779 244790 244785 244757 244765 244772 244758 244766 244689 244684 244679 244690 244685 244657 244665 244672 244658 244666 244589 24...

result:

ok 

Test #12:

score: 5
Accepted
time: 16ms
memory: 5820kb

input:

550

output:

1 12 5 2 13 302483 302491 302498 302484 302492 302458 302466 302473 302459 302467 302433 302441 302448 302434 302442 302408 302416 302423 302409 302417 302383 302391 302398 302384 302392 302358 302366 302373 302359 302367 302333 302341 302348 302334 302342 302308 302316 302323 302309 302317 302283 3...

result:

ok 

Test #13:

score: 5
Accepted
time: 18ms
memory: 6380kb

input:

710

output:

1 12 5 2 13 504083 504091 504098 504084 504092 504058 504066 504073 504059 504067 504033 504041 504048 504034 504042 504008 504016 504023 504009 504017 503983 503991 503998 503984 503992 503958 503966 503973 503959 503967 503933 503941 503948 503934 503942 503908 503916 503923 503909 503917 503883 5...

result:

ok 

Test #14:

score: 5
Accepted
time: 25ms
memory: 7136kb

input:

825

output:

1 8 16 2 7 680589 680584 680579 680590 680585 680557 680565 680572 680558 680566 680489 680484 680479 680490 680485 680457 680465 680472 680458 680466 680389 680384 680379 680390 680385 680357 680365 680372 680358 680366 680289 680284 680279 680290 680285 680257 680265 680272 680258 680266 680189 68...

result:

ok 

Test #15:

score: 5
Accepted
time: 27ms
memory: 7104kb

input:

880

output:

1 12 5 2 13 774383 774391 774398 774384 774392 774358 774366 774373 774359 774367 774333 774341 774348 774334 774342 774308 774316 774323 774309 774317 774283 774291 774298 774284 774292 774258 774266 774273 774259 774267 774233 774241 774248 774234 774242 774208 774216 774223 774209 774217 774183 7...

result:

ok 

Test #16:

score: 5
Accepted
time: 38ms
memory: 7284kb

input:

925

output:

1 8 16 2 7 855589 855584 855579 855590 855585 855557 855565 855572 855558 855566 855489 855484 855479 855490 855485 855457 855465 855472 855458 855466 855389 855384 855379 855390 855385 855357 855365 855372 855358 855366 855289 855284 855279 855290 855285 855257 855265 855272 855258 855266 855189 85...

result:

ok 

Test #17:

score: 5
Accepted
time: 34ms
memory: 7540kb

input:

990

output:

1 12 5 2 13 980083 980091 980098 980084 980092 980058 980066 980073 980059 980067 980033 980041 980048 980034 980042 980008 980016 980023 980009 980017 979983 979991 979998 979984 979992 979958 979966 979973 979959 979967 979933 979941 979948 979934 979942 979908 979916 979923 979909 979917 979883 9...

result:

ok