QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#41761#3836. So I'll Max Out My Constructive Algorithm SkillszhangchiWA 3ms3796kbC++776b2022-08-01 09:29:232022-08-01 09:29:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-01 09:29:24]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3796kb
  • [2022-08-01 09:29:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,Q,q,mod=0,p[100005],b[100005],ans[10000005],check=0,cur;
void trans(){
	mod++;
	int t=0,butt;
	int B=b[1];
	int next=p[1]; 
	while(t<n){
		butt=b[next];
		b[next]=B;
		B=butt;
		next=p[next];
		t++; 
	}
	//for(int i=1;i<=n;i++){
	//	printf("%d",b[i]);
	//}
	//printf("\n");
}
int main(){
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		b[i]=i;
		ans[0]+=i*i;
	}
	trans();
	for(int i=1;i<=n;i++){
		ans[1]+=b[i]*i;
	}
	cur=1;
	while(check==0){
		trans();
		cur++;
		for(int i=1;i<=n;i++){
			ans[cur]+=b[i]*i;
		}
		if(ans[cur]==ans[0]){
			check=1;
			mod=cur; 
		}
	}
	for(int i=1;i<=Q;i++){
		scanf("%d",&q);
		q=q%mod;
		printf("%d\n",ans[q]);
		
	}
} 

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3796kb

input:

1
2
4 3
2 1

output:

1
1

result:

wrong output format Unexpected end of file - int32 expected