QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417279#6748. Spin the Wheelericmegalovania#WA 1ms3988kbC++201.3kb2024-05-22 17:00:112024-05-22 17:00:12

Judging History

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

  • [2024-05-22 17:00:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3988kb
  • [2024-05-22 17:00:11]
  • 提交

answer

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

//#define ONLINE
#ifndef ONLINE
#define debug(...) fprintf(stderr,##__VA_ARGS__)
#else
#define debug(...) ;
#endif

using LL=long long;
using PII=pair<int,int>;

template<typename T>
inline T READ(){
	T x=0; bool f=0; char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return f?-x:x;
}
inline int read(){return READ<int>();}
inline LL readLL(){return READ<LL>();}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	int n=read(); LL sum=0;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		a[i]=read();
		sum+=a[i];
	}
	bool if_same=1;
	for(int i=1;i<n && if_same;i++){
		if(a[i]!=a[0]) if_same=0;
	}
	if(if_same){
		printf("%d",n+(a[0]!=0));
		return 0;
	}
	if(sum%n){
		printf("-1");
		return 0;
	}
	int pos=-1;
	for(int i=0;i<n;i++){
		if(!a[i]){
			pos=i;
			break;
		}
	}
	if(pos==-1){
		printf("-1");
		return 0;
	}
	int opt=a[(pos+1)%n],ans=opt+(pos>0);
	for(int i=0;i<n;i++){
		if((a[(pos+i+1)%n]-a[(pos+i)%n]+n)%n!=opt) ans=-1;
	}
	printf("%d",ans);
	return 0;
}

/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

100000
0 55555 11110 66665 22220 77775 33330 88885 44440 99995 55550 11105 66660 22215 77770 33325 88880 44435 99990 55545 11100 66655 22210 77765 33320 88875 44430 99985 55540 11095 66650 22205 77760 33315 88870 44425 99980 55535 11090 66645 22200 77755 33310 88865 44420 99975 55530 11085 66640 221...

output:

-1

result:

wrong answer 1st numbers differ - expected: '55555', found: '-1'