QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#399243#6748. Spin the WheelblhxzjrCompile Error//C++201.8kb2024-04-26 08:17:552024-04-26 08:17:57

Judging History

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

  • [2024-04-26 08:17:57]
  • 评测
  • [2024-04-26 08:17:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define int long long
#define none 1e9*(-1)
int n,m,k,_;#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define int long long
#define none 1e9*(-1)
int n,m,k,_;

constexpr int mx=(1<<17);
const int N=1e5+7;

int a[N];

void main2(){
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }    
    vector<int>d(n+1,0);
    vector<int>d1(n+1,1);
    d1[1]=1-n;
    int sum=0;
    int mx=-1;
    int cnt=1;
    rep(i,1,n){
        if(i==1)d[i]=a[i]-a[n];
        else d[i]=a[i]-a[i-1];
        sum+=d[i];
        mx=max(mx,abs(d[i]));
    }
    rep(i,1,n){
        if(mx!=d[i])
        if(mx+abs(d[i])!=n) cnt=0;
    }
    if(sum!=0){
        cout<<"-1"; return;
    }
    if(cnt)cout<<mx;
    else cout<<n+1-mx;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    _=1; 
    //cin>>_;
    while(_--){
        main2(); 
        if(_) cout<<endl;
    }
    return 0;
}

constexpr int mx=(1<<17);
const int N=1e5+7;

int a[N];

void main2(){
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }    
    vector<int>d(n+1,0);
    vector<int>d1(n+1,1);
    d1[1]=1-n;
    int sum=0;
    int mx=-1;
    int cnt=1;
    rep(i,1,n){
        if(i==1)d[i]=a[i]-a[n];
        else d[i]=a[i]-a[i-1];
        sum+=d[i];
        mx=max(mx,abs(d[i]));
    }
    rep(i,1,n){
        if(mx+abs(d[i])!=n) cnt=0;
    if(sum!=0){
        cout<<"-1"; return;
    }
    if(cnt)cout<<mx;
    else cout<<n+1-mx;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    _=1; 
    //cin>>_;
    while(_--){
        main2(); 
        if(_) cout<<endl;
    }
    return 0;
}

详细

answer.code:7:13: error: stray ‘#’ in program
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |             ^
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:22: error: ‘bits’ was not declared in this scope
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                      ^~~~
answer.code:7:27: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |                           ^~~~
      |                           std
answer.code:7:14: error: ‘include’ does not name a type
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |              ^~~~~~~
answer.code:13:5: error: redefinition of ‘long long int n’
   13 | int n,m,k,_;
      |     ^
answer.code:7:5: note: ‘long long int n’ previously declared here
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |     ^
answer.code:13:7: error: redefinition of ‘long long int m’
   13 | int n,m,k,_;
      |       ^
answer.code:7:7: note: ‘long long int m’ previously declared here
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |       ^
answer.code:13:9: error: redefinition of ‘long long int k’
   13 | int n,m,k,_;
      |         ^
answer.code:7:9: note: ‘long long int k’ previously declared here
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |         ^
answer.code:13:11: error: redefinition of ‘long long int _’
   13 | int n,m,k,_;
      |           ^
answer.code:7:11: note: ‘long long int _’ previously declared here
    7 | int n,m,k,_;#include<bits/stdc++.h>
      |           ^
answer.code:59:15: error: redefinition of ‘constexpr const long long int mx’
   59 | constexpr int mx=(1<<17);
      |               ^~
answer.code:15:15: note: ‘constexpr const long long int mx’ previously defined here
   15 | constexpr int mx=(1<<17);
      |               ^~
answer.code:60:11: error: redefinition of ‘const long long int N’
   60 | const int N=1e5+7;
      |           ^
answer.code:16:11: note: ‘const long long int N’ previously defined here
   16 | const int N=1e5+7;
      |           ^
answer.code:62:5: error: redefinition of ‘long long int a [100007]’
   62 | int a[N];
      |     ^
answer.code:18:5: note: ‘long long int a [100007]’ previously declared here
   18 | int a[N];
      |     ^
answer.code:64:6: error: re...