結果

問題 No.482 あなたの名は
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-11-29 01:44:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 75,224 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-18 09:35:19
合計ジャッジ時間 3,357 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,500 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 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,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 56 ms
4,376 KB
testcase_17 AC 57 ms
4,376 KB
testcase_18 AC 56 ms
4,504 KB
testcase_19 WA -
testcase_20 AC 57 ms
4,380 KB
testcase_21 AC 57 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 55 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 53 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 54 ms
4,376 KB
testcase_28 AC 54 ms
4,376 KB
testcase_29 AC 54 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        A[i]--;
    }
    
    int x = 0, y = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( A[i] == i ) { continue; }
        if ( A[A[i]] != i ) { x++; }
        if ( A[A[i]] == i ) { y++; }
    }
    y /=2;
        
    int z = y+max(0,x-1);
    
    if ( K < z ) { cout << "NO" << endl; }
    else {
        cout << ( (K - z)%2 ? "NO" : "YES" ) << endl;
    }
    
    return 0;
}
0