結果

問題 No.482 あなたの名は
ユーザー beetbeet
提出日時 2017-02-10 22:26:53
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 467 bytes
コンパイル時間 2,967 ms
コンパイル使用メモリ 143,756 KB
実行使用メモリ 5,168 KB
最終ジャッジ日時 2023-08-27 21:44:18
合計ジャッジ時間 14,001 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin>>n>>k;
  int d[n];
  for(int i=0;i<n;i++) cin>>d[i];
  for(int i=0;i<n;i++) d[i]--;
  int r=0;
  int u[n];
  memset(u,0,sizeof(u));
  for(int i=0;i<n;i++){
    if(u[i]) continue;
    int t=0,c=i;
    while(!u[c]){
      u[c]=1;
      c=d[c];
      t++;
    }
    r+=t-1;
  }
  //cout<<r<<endl;
  if(r>k||(r-k)%2) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}
0