QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790900#6748. Spin the WheelHJR#WA 5ms4112kbC++171.1kb2024-11-28 15:56:322024-11-28 15:56:32

Judging History

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

  • [2024-11-28 15:56:32]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:4112kb
  • [2024-11-28 15:56:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cout<<#x<<": "<<x<<endl
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll=long long;
using ull=unsigned long long;
const int N=200010;
int a[N],n;
int dis(int x,int y){
    if(x>=y){
        return x-y;
    }else{
        return n+x-y;
    }
}
void solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0,d=dis(a[1],a[0]);
    for(int i=0;i<n;i++){
        if(dis(a[(i+1)%n],a[i])!=d){
            cout<<-1<<endl;
            return;
        }
    }
    if(d==0){
        if(a[0]==0){
            cout<<0<<endl;
        }else{
            cout<<-1<<endl;
        }
        return;
    }
    ans+=d-1;
    if(a[0]!=0){
        ans+=2;
    }
    cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t=1;
    while(t--){
        solve();
    }
}
/*
贡献法
正难则反
数小状压
关系连边
拆位
广义单调性
最长转最短
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3720kb

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 4112kb

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:

55554

result:

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