結果
| 問題 |
No.100 直列あみだくじ
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-07-26 15:15:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 376 bytes |
| コンパイル時間 | 1,940 ms |
| コンパイル使用メモリ | 199,164 KB |
| 最終ジャッジ日時 | 2025-01-30 14:16:53 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
4 | main(){
| ^~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n,i,x,c;
main(){
cin>>n;
vector<int> A(n),B(n),r;
for(i=0;n>i;i++)cin>>A[i],A[i]--;
for(i=0;n>i;i++){
x=i;c=0;
while(!B[x])B[x]=1,x=A[x],c++;
if(c%2 == 0)r.push_back(c);
}sort(r.begin(),r.end());x=1;
for(i=0;r.size()>i;i++)x&=r[i]==r[++i];
cout << (x?"Yes":"No") << endl;
}