結果

問題 No.482 あなたの名は
ユーザー tnakao0123tnakao0123
提出日時 2017-02-12 17:54:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,197 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-08-28 14:51:57
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 482.cc: No.482 あなたの名は - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int ds[MAX_N], es[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  ll k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ds[i]);
    ds[i]--;
    es[ds[i]] = i;
  }

  int c = 0;
  for (int i = 0; i < n; i++) {
    int j = es[i];
    if (i != j) {
      swap(ds[i], ds[j]);
      swap(es[i], es[j]);
      c++;
    }
  }
  //for (int i = 0; i < n; i++) printf("%d ", ds[i]); putchar('\n');
  //for (int i = 0; i < n; i++) printf("%d ", es[i]); putchar('\n');
  //printf("c=%d\n", c);

  if (k >= c && ((k - c) & 1LL) == 0LL) puts("YES");
  else puts("NO");
  return 0;
}
0