結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-04 00:33:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 557 bytes |
| コンパイル時間 | 677 ms |
| コンパイル使用メモリ | 72,280 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 02:36:41 |
| 合計ジャッジ時間 | 2,854 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000007
int main() {
int n,cnt=0;
long long int k;
cin >> n >> k;
vector<int>d(n);
rep(i, n)
cin >> d[i];
while (true) {
bool flag = true;
rep(i, n) {
if (d[i] != i + 1)
{
swap(d[i], d[d[i] - 1]);
cnt++;
flag = false;
}
}
if (flag)
break;
}
string s = (k - cnt) % 2 ||(k-cnt)<0? "NO" : "YES";
cout << s << endl;
}