結果

問題 No.482 あなたの名は
ユーザー pinpin
提出日時 2017-02-11 00:02:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 895 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 52,036 KB
実行使用メモリ 5,408 KB
最終ジャッジ日時 2023-08-28 10:23:15
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

int main(void){
      long long int N ,K ;
     cin >> N >> K ;
     long long int a[N+1] ;
     bool used[N+1] ;
     
     for(int i=1;i<=N;i++){
          cin >> a[i] ;
          used[i] = false ;
     }
     
     
     int count = 0 ;
     for(int i=1;i<=N;i++){
          int m = 0 ;
          if(!used[i] && i != a[i]){
               used[i] = true ;
               
               int t = a[i] ;
               int s = a[t] ;
               used[t] = true ;
               
               while(t != i){
                    count++ ;
                    t = s ;
                    s = a[t] ;
                    used[t] = true ;
                    count += m++ ;
               }
          }
     }
   
     if(count<=K && (K-count)%2 == 0){
          cout << "YES" << endl ;
     }else{
          cout << "NO" << endl ;
          
     }

}
0