結果

問題 No.482 あなたの名は
ユーザー nyan_nyan_farmnyan_nyan_farm
提出日時 2017-02-10 23:06:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 144,040 KB
実行使用メモリ 5,332 KB
最終ジャッジ日時 2023-08-27 23:31:51
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int used[200000];

int main(){
    int n,k,room;
    cin>>n>>k;
    int d[n];
    room=n;
    for(int i=0; i<n; i++){
        int in;
        cin>>in;
        in--;
        d[i]=in;
    }
    //for(int i=0; i<n; i++)cout<<d[i]<<endl;
    for(int i=0; i<n; i++){
        if(!used[i]){
            if(i==d[d[i]]&&i!=d[i]){
                used[i]=1;
                used[d[i]]=1;
                k--;
                room-=2;
                //cout<<'b'<<endl;
            }
            else if(i==d[i]){
                used[i]=1;
                room--;
                //cout<<'a'<<endl;
            }
        }
    }
    cout<<((k-room>=0&&(k-room)%2==0)?("YES"):("NO"))<<endl;
    //cout<<k<<' '<<room<<endl;
    //for(int i=0; i<n; i++)cout<<d[i]<<endl;
    return 0;
}
0