QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#399242 | #6748. Spin the Wheel | blhxzjr | Compile Error | / | / | C++20 | 896b | 2024-04-26 08:17:06 | 2024-04-26 08:17:07 |
Judging History
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,_;
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: In function ‘void main2()’: answer.code:40:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 40 | signed main(){ | ^~ answer.code:40:12: note: remove parentheses to default-initialize a variable 40 | signed main(){ | ^~ | -- answer.code:40:12: note: or replace parentheses with braces to value-initialize a variable answer.code:40:14: error: a function-definition is not allowed here before ‘{’ token 40 | signed main(){ | ^ answer.code:49:2: error: expected ‘}’ at end of input 49 | } | ^ answer.code:14:13: note: to match this ‘{’ 14 | void main2(){ | ^