QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226659#5750. SiteswappiaoyunWA 1ms6008kbC++201.1kb2023-10-26 13:14:552023-10-26 13:14:55

Judging History

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

  • [2023-10-26 13:14:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6008kb
  • [2023-10-26 13:14:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define otto auto
const int MAXN=1e6+10;
const int INF=1ll*1e7*1e9;
int T,N,M,K,P,Q;
int a[MAXN];
int vis[MAXN];
int ans[4];
void prepare(){
	scanf("%lld",&N);
	for(int i = 0;i < N;i++){
		scanf("%lld",&a[i]);
		vis[i] = 0;
	}
	ans[0] = ans[1] = ans[2] = 0;
	for(int i = 0;i < N; i++){
		if(vis[i]) continue;
		int flag[2] = {0,0};
		int len = 0;
		for(int u = i;!vis[u%N];u += a[u%N]){
			vis[u%N] = 1;
			flag[u&1] = 1;
			len += a[u%N];
		}
		if(flag[0] && flag[1]){
			ans[2] += len / N;
			continue;
		}
		if(flag[0]){
			if(N&1){
				ans[1] += len / N / 2;
				ans[0] += len / N - len / N / 2;
			}
			else{
				ans[0] += len / N;
			}
		}
		if(flag[1]){
			if(N&1){
				ans[0] += len / N / 2;
				ans[1] += len / N - len / N / 2;
			}
			else{
				ans[1] += len / N;
			}
		}
	}
	printf("%lld %lld %lld\n",ans[0],ans[1],ans[2]);
}

signed main(){
	//ios::sync_with_stdio(0);
	T=1;
	scanf("%lld",&T);
	while(T--){
	    prepare();
	}
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5940kb

input:

3
3
1 5 0
6
4 6 4 0 4 0
2
6 4

output:

0 0 2
2 1 0
3 2 0

result:

ok 9 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 6004kb

input:

100
10
94 8 4 52 7 53 16 96 29 1
10
23 35 96 34 86 39 16 72 63 96
10
51 2 46 21 15 31 41 28 42 83
10
75 67 64 88 46 98 3 17 14 98
10
24 77 54 48 16 37 23 88 99 84
10
52 93 44 87 84 80 37 22 73 28
10
35 80 96 60 75 19 100 63 54 88
10
38 49 63 68 29 67 3 57 68 48
10
89 57 51 21 61 16 100 73 99 83
10
6...

output:

2 0 34
0 0 56
0 0 36
0 0 57
4 0 51
0 13 47
25 14 28
0 0 49
10 0 55
0 0 30
9 0 48
0 0 48
15 11 22
0 7 34
9 0 39
4 7 26
9 0 56
6 10 49
6 5 32
0 0 45
7 4 44
8 0 46
7 4 60
24 19 0
0 0 57
0 13 28
9 1 37
0 0 58
7 0 38
0 0 40
6 6 21
3 9 31
3 10 51
7 9 28
19 10 39
0 3 51
22 8 29
0 8 40
7 0 51
0 0 40
0 16 45...

result:

ok 300 numbers

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 6008kb

input:

100
54
386 856 526 874 268 682 718 686 344 116 412 25 82 99 203 496 2 949 757 584 713 137 518 782 485 769 852 483 906 918 152 211 561 355 527 591 585 506 57 49 929 767 317 287 475 186 267 199 227 390 124 373 309 444
85
491 676 471 547 85 660 974 510 349 341 89 557 936 180 632 919 810 887 498 426 644...

output:

0 17 437
17 16 484
33 32 494
4 2 413
0 7 490
1 2 509
0 0 424
27 28 459
0 38 386
1 0 473
39 38 590
7 8 506
22 0 490
0 41 472
66 67 447
4 3 519
0 0 441
0 55 423
0 0 467
20 21 518
0 0 517
0 0 565
5 7 474
0 0 492
0 0 495
126 127 308
2 6 437
47 54 302
0 16 510
21 0 482
110 110 302
3 31 334
30 0 355
54 81...

result:

wrong answer 4th numbers differ - expected: '16', found: '17'