QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407308#6748. Spin the Wheeltjf4#WA 22ms4852kbC++20960b2024-05-08 15:08:122024-05-08 15:08:14

Judging History

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

  • [2024-05-08 15:08:14]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:4852kb
  • [2024-05-08 15:08:12]
  • 提交

answer

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;
const int inf=0x3f;
const int N=2e5+10;
const int mod=998244353;
ll n,p[N];
vi g;
vi d;
int main() {
	cin>>n;
	int res=0;
	for(int i=1;i<=n;i++) cin>>p[i],d.push_back(p[i]);
	sort(d.begin(),d.end());
	for(int i=0;i<n;i++) {
		if(i!=d[i]) {
			cout<<"-1";
			return 0;
		}
	}
	if(p[1]!=0) res++;
	for(int i=1;i<=n;i++) g.push_back(p[i]);
	for(int i=1;i<=n;i++) g.push_back(p[i]);
	reverse(g.begin(),g.end());
	while(!g.empty()&&g.back()>0) g.pop_back();
	reverse(g.begin(),g.end());
	while(g.size()>n) g.pop_back();
	int pd=1;
	for(ll i=2;i<n&&pd;i++) {
		if(g[1]*i%n!=g[i]) pd=0;
	}
	res+=g[1];
	if(!pd) res=-1;
	cout<<res;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 22ms
memory: 4852kb

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'