QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88823#5750. SiteswapFengfengWA 3ms7520kbC++14926b2023-03-17 16:34:492023-03-17 16:34:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-17 16:34:53]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7520kb
  • [2023-03-17 16:34:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e6+10;

int a[N];
int n;
int vp[N];
bool vis[N];
int dfs(int x)
{
	if(vp[x]!=-1) return vp[x]=a[x]%2;
	vp[x]=x%2;
	return vp[x]=dfs((x+a[x])%n)|vp[x];
}
long long qr(int x)
{
	if(vis[x]) return 0;
	vis[x]=true;
	return qr((x+a[x])%n)+a[x];
}
void solve()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		vis[i]=false;
		vp[i]=-1;
	}
	if(n&1)
	{
		for(int i=0;i<n;i++)
		{
			a[i+n]=a[i];
			vis[i+n]=false;
			vp[i+n]=-1;
		}
		n*=2;
	}
	long long ans1=0,ans2=0,ans3=0;
	for(int i=0;i<n;i++)
	{
		if(vp[i]!=-1) continue; 
		int t=dfs(i);
		if(t) ans3+=qr(i)/n;
		else if(i%2==0)
		{
			ans1+=qr(i)/n;
		}
		else  ans2+=qr(i)/n;
		
	}
	cout<<ans1<<" "<<ans2<<" "<<ans3<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	cin>>t;
	while(t--)
		solve();
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 5436kb

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: -100
Wrong Answer
time: 3ms
memory: 7520kb

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 8 52
25 14 28
0 0 49
10 0 55
0 0 30
9 0 48
0 0 48
15 0 33
0 7 34
9 0 39
4 1 32
9 0 56
6 10 49
6 5 32
0 0 45
7 4 44
8 0 46
7 4 60
24 4 15
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
0...

result:

wrong answer 17th numbers differ - expected: '13', found: '8'