結果

問題 No.482 あなたの名は
ユーザー btkbtk
提出日時 2017-02-11 10:57:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,014 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 168,192 KB
実行使用メモリ 5,492 KB
最終ジャッジ日時 2023-08-28 16:20:21
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 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 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 24 ms
5,376 KB
testcase_16 AC 23 ms
5,464 KB
testcase_17 AC 24 ms
5,464 KB
testcase_18 AC 23 ms
5,424 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 23 ms
5,468 KB
testcase_21 AC 23 ms
5,372 KB
testcase_22 AC 24 ms
5,472 KB
testcase_23 AC 23 ms
5,492 KB
testcase_24 AC 23 ms
5,468 KB
testcase_25 AC 23 ms
5,428 KB
testcase_26 AC 23 ms
5,376 KB
testcase_27 AC 23 ms
5,432 KB
testcase_28 AC 23 ms
5,368 KB
testcase_29 AC 21 ms
5,388 KB
testcase_30 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    LL N,K;
    cin>>N>>K;
    vector<LL> v(N);
    cin>>v;
    vector<int> used(N,0);
    LL f=0;
    REP(i,N)if(!used[i]){
        used[i]=1;
        int sz=1;
        for(int u=v[i]-1;!used[u];u=v[u]-1)
            used[u]=1,sz++;
        if(sz>2)f=1;
        K-=sz-1;
    }
    if(K>=0&&K%2==0)cout<<"YES"<<endl;
    //else if(K>=0&&f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
                        

    return 0;
}
0