結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
Izayoi_R_sakura
|
| 提出日時 | 2020-05-15 22:38:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,901 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 77,772 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-09-19 11:45:37 |
| 合計ジャッジ時間 | 2,535 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
ソースコード
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;
//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//void chmin(ll &a,ll b){if(a>b) a = b ;}
int main(){
ll n ; cin >> n ;
ll f,l ;
vvll cnt(n+1,vll(0)) ;
for(int i=0;i<n;i++){
ll a ; cin >> a ;
if(i==0) f = a ;
if(i==n-1) l = a ;
cnt.at(a).emplace_back(i+1) ;
}
for(int i=0;i<=n;i++){
if(cnt.at(i).size()<2) continue ;
if(cnt.at(i).at(0)==1){
vll sub ;
for(int j=0;j<cnt.at(i).size();j++){
if(j!=0&&cnt.at(i).at(j-1)+1!=cnt.at(i).at(j)) break ;
sub.emplace_back(cnt.at(i).at(j)) ;
}
for(int j=0;j<sub.size();j++) cnt.at(i).emplace_back(sub.at(j)+n) ;
for(int j=sub.size();j<cnt.at(i).size()-1;j++){
if(cnt.at(i).at(j+1)-cnt.at(i).at(j)!=1){
cout << -1 << endl ;
return 0 ;
}
}
}else{
for(int j=0;j<cnt.at(i).size()-1;j++){
if(cnt.at(i).at(j+1)-cnt.at(i).at(j)!=1){
cout << -1 << endl ;
return 0 ;
}
}
}
}
cout << (f==l) << endl ;
}
Izayoi_R_sakura