結果

問題 No.482 あなたの名は
ユーザー nyan_nyan_farmnyan_nyan_farm
提出日時 2017-02-10 23:33:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 1,173 ms
コンパイル使用メモリ 143,836 KB
実行使用メモリ 5,224 KB
最終ジャッジ日時 2023-08-28 09:17:42
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int used[200001];
int d[200001];

int main(){
    long long n,k,room;
    cin>>n>>k;
    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+(room>0)>=0&&(k-room+(room>0))%2==0)?("YES"):("NO"))<<endl;
    //cout<<k<<' '<<room<<endl;
    //for(int i=0; i<n; i++)cout<<d[i]<<endl;
    return 0;
}
0