QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418824#6748. Spin the WheelAndeviking#WA 8ms4536kbC++201.1kb2024-05-23 15:59:412024-05-23 15:59:43

Judging History

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

  • [2024-05-23 15:59:43]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:4536kb
  • [2024-05-23 15:59:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define range(x) (x).begin(),(x).end()
const int dir[][2]={1,0,-1,0,0,1,0,-1};

void solve()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto& c:v)
        cin>>c;
    set<int>st;
    for(const auto& c:v)
        st.insert(c);
    if(st.size()==1){
        if(*st.begin()==0)
            cout<<"0\n";
        else
            cout<<n+1<<'\n';
        return;
    }
    else if(st.size()<n){
        cout<<"-1\n";
        return;
    }
    int now=(v[1]-v[0]+n)%n;
    for(int i=2;i<n;++i){
        if(now!=(v[i]-v[i-1]+n)%n){
            cout<<"-1\n";
            return;
        }
    }

    if((v[0]-v.back()+n)%n!=now){
        cout<<"-1\n";
        return;
    }

    int cnt=now;
    vector<int>ck(n);
    for(int i=0;i<n;++i)
        ck[i]=1ll*i*cnt%n;
    if(ck==v)
        cout<<cnt<<'\n';
    else
        cout<<cnt+1<<'\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: 0ms
memory: 3572kb

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 4536kb

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'