QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#30522#1253. Abstract Circular CoverqazswedxAC ✓4802ms292868kbC++2.3kb2022-04-29 20:30:472022-04-29 20:30:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-29 20:30:48]
  • 评测
  • 测评结果:AC
  • 用时:4802ms
  • 内存:292868kb
  • [2022-04-29 20:30:47]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct pt
{
	int v[905][905];
	pt(){memset(v,0x3f,sizeof(v));}
}f[45],g[45];
int n,sn;
int mn1=1,mn2=1;
pt operator*(const pt &x,const pt &y)
{
	pt z;
	for(int i=1;i<=n;i++)
		for(int j=mn1;j<=n;j++)
		{
			int u=(i+j-1)%n+1,k,*p=z.v[i],val=x.v[i][j];
			const int *q=y.v[u];
			for(k=mn2;j+k+3<=n;k+=4)
			{
			/*	z.v[i][j+k]=min(z.v[i][j+k],x.v[i][j]+y.v[u][k]);
				z.v[i][j+k+1]=min(z.v[i][j+k+1],x.v[i][j]+y.v[u][k+1]);
				z.v[i][j+k+2]=min(z.v[i][j+k+2],x.v[i][j]+y.v[u][k+2]);
				z.v[i][j+k+3]=min(z.v[i][j+k+3],x.v[i][j]+y.v[u][k+3]);*/
				p[j+k]=min(p[j+k],val+q[k]);
				p[j+k+1]=min(p[j+k+1],val+q[k+1]);
				p[j+k+2]=min(p[j+k+2],val+q[k+2]);
				p[j+k+3]=min(p[j+k+3],val+q[k+3]);
			}
		/*	if(j+k<=n) z.v[i][j+k]=min(z.v[i][j+k],x.v[i][j]+y.v[u][k]);
			if(j+k+1<=n) z.v[i][j+k+1]=min(z.v[i][j+k+1],x.v[i][j]+y.v[u][k+1]);
			if(j+k+2<=n) z.v[i][j+k+2]=min(z.v[i][j+k+2],x.v[i][j]+y.v[u][k+2]);
			if(j+k+3<=n) z.v[i][j+k+3]=min(z.v[i][j+k+3],x.v[i][j]+y.v[u][k+3]);*/
			if(j+k<=n) p[j+k]=min(p[j+k],val+q[k]);
			if(j+k+1<=n) p[j+k+1]=min(p[j+k+1],val+q[k+1]);
			if(j+k+2<=n) p[j+k+2]=min(p[j+k+2],val+q[k+2]);
			if(j+k+3<=n) p[j+k+3]=min(p[j+k+3],val+q[k+3]);
		}
//	printf("---\n");
	return z;
}
int solve(const pt &x,const pt &y)
{
	int ans=1e9;
//	for(int i=1;i<=n;i++)
//		for(int j=1;j<=n;j++)
//			printf("i=%d,j=%d,y=%d\n",i,j,y.v[i][j]);
	if(y.v[1][n]>1e9)
	{
		for(int i=1;i<=n;i++)
		{
			ans=min(ans,x.v[i][n]);
		//	ans=min(ans,y.v[i][n]);
	//		printf("i=%d,x=%d,y=%d,ans=%d\n",i,x.v[i][n],y.v[i][n],ans);
		}
		return ans;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++)
		{
			int u=(i+j-1)%n+1;
			ans=min(ans,x.v[i][j]+y.v[u][n-j]);
		//	printf("i=%d,j=%d,u=%d,ans=%d,x=%d,y=%d\n",i,j,u,ans,x.v[i][j],y.v[u][n-j]);
		}
	return ans;
}
int main()
{
//	freopen("A.in","r",stdin);
	scanf("%d",&n);
	sn=1;
	while(1ll*(sn+1)*(sn+1)<=n) sn++;
	sn++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&f[1].v[i][j]);
	for(int i=2;i<=sn;i++)
		f[i]=f[i-1]*f[1];
	g[1]=f[sn];
	for(int i=2;i<=sn;i++)
	{
		mn1=(i-1)*sn,mn2=sn;
		g[i]=g[i-1]*g[1];
	}
	for(int i=1;i<=n;i++)
		printf("%d ",solve(f[(i-1)%sn+1],g[(i-1)/sn]));
	printf("\n");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 48ms
memory: 292820kb

input:

3
10 12 23
7 4 11
8 5 3

output:

3 12 25 

result:

ok 3 tokens

Test #2:

score: 0
Accepted
time: 43ms
memory: 292760kb

input:

1
15

output:

15 

result:

ok "15"

Test #3:

score: 0
Accepted
time: 4802ms
memory: 292868kb

input:

850
467844 492130 605609 643857 26979 997775 457911 823516 154840 985025 993710 334965 480280 45505 851380 765414 512285 661374 745909 563360 878563 887945 542943 288759 124012 159576 828454 705380 24125 806150 695873 109057 933855 632721 259819 784272 398751 935451 393059 788917 560334 786155 54986...

output:

260 583 4456 6370 5867 10516 8445 11322 22257 25758 29686 36603 43777 37503 42305 54915 55969 74889 75170 96572 108980 118941 131680 143190 159544 172374 192023 199700 216054 236664 249640 263857 282365 298719 319329 332305 346522 367087 401391 418048 432265 452830 486603 507925 541698 567714 601189...

result:

ok 850 tokens

Test #4:

score: 0
Accepted
time: 4779ms
memory: 292868kb

input:

850
1 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 ...

output:

151599 151600 151601 151602 151603 151604 151605 151606 151607 151608 151609 151610 151611 151612 151613 151614 151615 151616 151617 151618 151619 151620 151621 151622 151623 151624 151625 151626 151627 151628 151629 151630 151631 151632 151633 151634 151635 151636 151637 151638 151639 151640 151641...

result:

ok 850 tokens

Test #5:

score: 0
Accepted
time: 4754ms
memory: 292856kb

input:

850
1 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 100000...

output:

890977 890978 890979 890980 890981 890982 890983 890984 890985 890986 890987 890988 890989 890990 890991 890992 890993 890994 890995 890996 890997 890998 890999 891000 891001 891002 891003 891004 891005 891006 891007 891008 891009 891010 891011 891012 891013 891014 891015 891016 891017 891018 891019...

result:

ok 850 tokens

Test #6:

score: 0
Accepted
time: 4682ms
memory: 292764kb

input:

850
1 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 100000...

output:

907746 907747 907748 907749 907750 907751 907752 907753 907754 907755 907756 907757 907758 907759 907760 907761 907762 907763 907764 907765 907766 907767 907768 907769 907770 907771 907772 907773 907774 907775 907776 907777 907778 907779 907780 907781 907782 907783 907784 907785 907786 907787 907788...

result:

ok 850 tokens

Test #7:

score: 0
Accepted
time: 4680ms
memory: 292784kb

input:

850
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 ...

output:

28234 28235 56469 1000003 1000004 1000005 1028239 1056473 2000007 2028241 2056475 2112942 3028243 3084710 3141177 4056478 4141178 5056479 5084713 6056480 6084714 7056481 7084715 8056482 8084716 9056483 9141183 10084717 10141184 11084718 11141185 12084719 12169419 13112953 13225886 14169420 14254120 ...

result:

ok 850 tokens

Test #8:

score: 0
Accepted
time: 4635ms
memory: 292772kb

input:

850
1 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 100000...

output:

582215 582216 582217 582218 582219 582220 582221 582222 582223 582224 582225 582226 582227 582228 582229 582230 582231 582232 582233 582234 582235 582236 582237 582238 582239 582240 582241 582242 582243 582244 582245 582246 582247 582248 582249 582250 582251 582252 582253 582254 582255 582256 582257...

result:

ok 850 tokens

Test #9:

score: 0
Accepted
time: 4740ms
memory: 292784kb

input:

850
768218 610634 661724 705689 568784 625934 642404 518390 770945 730456 585663 767829 542978 676860 749115 618394 556185 551389 606683 780789 727530 653166 556590 687842 513981 526738 525071 495795 628271 779603 714657 675799 775960 684902 653856 493464 701931 631143 728685 627656 611082 721745 74...

output:

703748 1406181 2109573 2812314 3515573 4218485 4921742 5624683 6327909 7030849 7734078 8437041 9140280 9843217 10546489 11249418 11952678 12655630 13358885 14061831 14765076 15468031 16171269 16874235 17577477 18280468 18983670 19686669 20389893 21092902 21796134 22499139 23202341 23905340 24608564 ...

result:

ok 850 tokens

Test #10:

score: 0
Accepted
time: 4797ms
memory: 292784kb

input:

850
589253 589253 589253 589253 589253 589253 589253 589253 589251 589253 589253 589253 589253 589253 589253 589253 589253 589251 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589253 589251 589253 589253 589253 589253 589253 589253 589253 58...

output:

589251 1178502 1767753 2357004 2946255 3535506 4124757 4714008 5303259 5892510 6481761 7071012 7660263 8249514 8838765 9428016 10017267 10606518 11195769 11785020 12374271 12963522 13552773 14142024 14731275 15320526 15909777 16499028 17088279 17677530 18266781 18856032 19445283 20034534 20623785 21...

result:

ok 850 tokens

Test #11:

score: 0
Accepted
time: 4765ms
memory: 292776kb

input:

850
825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 825732 82...

output:

825732 1651463 2477194 3302925 4128656 4954387 5780119 6605850 7431581 8257313 9083044 9908776 10734507 11560238 12385970 13211701 14037433 14863164 15688896 16514627 17340359 18166090 18991822 19817553 20643285 21469016 22294748 23120480 23946211 24771943 25597674 26423406 27249137 28074869 2890060...

result:

ok 850 tokens

Test #12:

score: 0
Accepted
time: 4603ms
memory: 292768kb

input:

850
640315 640315 640315 640315 640314 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 640315 64...

output:

640315 1280629 1920943 2561257 3201571 3841885 4482199 5122513 5762827 6403140 7043454 7683768 8324082 8964396 9604710 10245024 10885338 11525652 12165966 12806280 13446594 14086908 14727222 15367536 16007850 16648164 17288478 17928792 18569106 19209420 19849734 20490048 21130362 21770676 22410990 2...

result:

ok 850 tokens

Test #13:

score: 0
Accepted
time: 4701ms
memory: 292812kb

input:

850
618210 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 618211 61...

output:

618211 1236421 1854631 2472841 3091051 3709261 4327471 4945681 5563891 6182100 6800310 7418520 8036730 8654940 9273150 9891360 10509570 11127780 11745990 12364200 12982410 13600620 14218830 14837040 15455250 16073460 16691670 17309880 17928090 18546300 19164510 19782720 20400930 21019140 21637350 22...

result:

ok 850 tokens

Test #14:

score: 0
Accepted
time: 4783ms
memory: 292772kb

input:

850
410246 517750 494733 628963 673141 644272 428126 608311 446746 658126 611717 592980 607113 599213 550074 667277 470673 646193 404335 601296 650701 678937 457903 642355 668205 413922 602327 510606 688468 495640 625304 495701 466255 536810 510770 617772 687747 432219 692704 467264 661509 670756 57...

output:

699291 1397564 2096452 2795059 3494020 4192630 4891527 5590118 6289095 6987703 7686625 8385216 9084193 9782797 10481730 11180394 11879327 12577970 13276905 13975551 14674484 15373163 16072096 16770792 17469699 18168401 18867312 19566011 20264919 20963623 21662531 22361247 23060155 23758883 24457783 ...

result:

ok 850 tokens

Test #15:

score: 0
Accepted
time: 4679ms
memory: 292848kb

input:

850
704087 816247 645258 737074 608288 564263 717013 677084 764728 597755 648728 782329 604022 751382 756393 593259 770614 594118 815506 672511 775688 565900 807326 761415 777958 623044 632540 692791 764736 824110 785422 764868 768541 669903 602894 603086 758149 764038 647535 744498 593798 704896 82...

output:

730800 1461599 2192398 2923197 3653996 4384795 5115594 5846393 6577192 7307990 8038789 8769588 9500387 10231186 10961985 11692784 12423583 13154382 13885181 14615980 15346779 16077578 16808377 17539176 18269975 19000774 19731573 20462372 21193171 21923970 22654769 23385568 24116367 24847166 25577965...

result:

ok 850 tokens