結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
tsutaj
|
| 提出日時 | 2019-01-16 21:13:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 510 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 69,124 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 16:54:48 |
| 合計ジャッジ時間 | 3,209 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 RE * 6 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, K; cin >> N >> K;
vector<int> p(N), used(N);
for(int i=0; i<N; i++) {
cin >> p[i]; p[i]--;
}
int sum = 0;
for(int i=0; i<N; i++) {
int cnt = 0, idx = i;
for(; used[idx] == false; idx = p[idx]) used[idx] = true, cnt++;
if(cnt > 0) sum += cnt - 1;
}
if(sum <= K and K % 2 == sum % 2) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
tsutaj