QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#176349#7072. PhotographlinninsWA 0ms3656kbC++201.8kb2023-09-11 15:50:142023-09-11 15:50:14

Judging History

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

  • [2023-09-11 15:50:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2023-09-11 15:50:14]
  • 提交

answer

#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

const int maxn = 1e5+10;
struct Node{
	int value,i;
	Node *last,*next;
}Height[maxn];
int Map[maxn];
int Check[maxn];
int point = 1;

int cmp(Node a,Node b){
	return a.value<b.value;
}

int main()
{
	int n,T;
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;i++){
		scanf("%d",&Height[i].value);
		Height[i].i = i;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&Map[i]);
	}
	
	sort(Height+1,Height+n+1,cmp);
	
	long long Fst_Ans = 0;
	
	for(int i=0;i<=n;i++){
		Fst_Ans += (Height[i+1].value-Height[i].value) * (Height[i+1].value-Height[i].value);
	}
	T+=1;
	while(T--){
		
		for(int i=1;i<=n;i++){
			Map[Height[i].i];
			Height[i-1].next = &Height[i];
			Height[i+1].last = &Height[i];
			Height[i].next = &Height[i+1];
			Height[i].last = &Height[i-1];
		}
		
		long long Ans = Fst_Ans;
		long long New_Ans = Fst_Ans;
		Ans -= Height[1].value * Height[1].value;
		Ans -= Height[n].value * Height[n].value;
		for(int i=point-1,j=1;j<=n-2;i--,j++){
			if(i<=0)
				i+=n;
			Check[Map[i]] = 1;
			New_Ans -= (Height[Map[i]].value-Height[Map[i]].last->value)*(Height[Map[i]].value-Height[Map[i]].last->value);
			New_Ans -= (Height[Map[i]].value-Height[Map[i]].next->value)*(Height[Map[i]].value-Height[Map[i]].next->value); 
			New_Ans += (Height[Map[i]].next->value-Height[Map[i]].last->value)*(Height[Map[i]].next->value-Height[Map[i]].last->value);
			Height[Map[i]].last->next = Height[Map[i]].next;
			Height[Map[i]].next->last = Height[Map[i]].last;
			Ans += New_Ans;
			Ans -= Height[0].next->value*Height[0].next->value;
			Ans -= Height[n+1].last->value*Height[n+1].last->value;
		}
		int p;
		printf("%lld\n",Ans);
		if(T!=0){
			scanf("%d",&p);
			point += p+Ans;
			point %= n;
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5 4
1 2 3 4 5
1 2 3 4 5
6
6
8
10

output:

10
10
13
21
36

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 1660kb

input:

1 100
9139
1
815121916
455099013
31761433
46418945
11466871
709189476
658667824
977821005
511405192
843598992
501074199
638564514
680433292
994431111
584582554
452689372
642414314
863578235
135133204
438404803
67246919
492858783
447116205
723252212
948645336
191050463
326944894
685212650
828613990
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 101 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 1608kb

input:

2 100
9859 8096
2 1
692572036
546897526
810778144
630776743
411450468
47253421
344401774
898201838
853758724
613913038
441359030
921437570
855535818
106915566
108572797
533697405
315571976
503278469
849317884
327448764
867873746
718830950
808828124
547579134
751502930
595486247
629024078
79153124
34...

output:

3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108...

result:

ok 101 lines

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

3 100
5987 4237 8891
3 1 2
760669141
361439344
393719043
515372386
379329282
704177992
446687639
688441074
939269095
570763162
492018656
161714447
596461367
384092911
304150759
54574629
350079205
804917425
296791887
311704304
120533843
281070757
787668201
311851357
243944555
860970785
463288414
9962...

output:

33155432
33155432
33155432
19928932
14558216
33155432
33155432
14558216
33155432
33155432
33155432
14558216
19928932
19928932
14558216
14558216
33155432
33155432
33155432
19928932
19928932
19928932
14558216
33155432
33155432
14558216
19928932
14558216
33155432
19928932
33155432
19928932
33155432
145...

result:

wrong answer 4th lines differ - expected: '46381932', found: '19928932'