結果

問題 No.482 あなたの名は
ユーザー notetonousnotetonous
提出日時 2017-08-03 17:47:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 57,304 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 01:37:04
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 56 ms
5,376 KB
testcase_16 AC 59 ms
5,376 KB
testcase_17 AC 59 ms
5,376 KB
testcase_18 AC 60 ms
5,376 KB
testcase_19 AC 56 ms
5,376 KB
testcase_20 AC 56 ms
5,376 KB
testcase_21 AC 59 ms
5,376 KB
testcase_22 AC 58 ms
5,376 KB
testcase_23 AC 57 ms
5,376 KB
testcase_24 AC 60 ms
5,376 KB
testcase_25 AC 58 ms
5,376 KB
testcase_26 AC 57 ms
5,376 KB
testcase_27 AC 57 ms
5,376 KB
testcase_28 AC 58 ms
5,376 KB
testcase_29 AC 57 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int G[200002];
bool used[200002];
long long int Count;
void dfs(int v){
  //cout << v << endl;
  used[v]=true;
  int n=G[v];
  if(!used[n])dfs(n);
}
int main(){
  int N;
  long long int K;
  cin >> N >> K;
  for(int i=1;i<=N;i++){
    int d;
    cin >> d;
    G[i]=d;
    
  }
  for(int i=1;i<=N;i++){
    if(!used[i]){
      dfs(i);
      Count++;
    }
  }
  Count=N-Count;
  if(K%2==Count%2)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
  
0