結果
問題 |
No.482 あなたの名は
|
ユーザー |
|
提出日時 | 2017-02-10 22:30:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 450 bytes |
コンパイル時間 | 839 ms |
コンパイル使用メモリ | 69,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-28 06:46:53 |
合計ジャッジ時間 | 3,115 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 12 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int n; long long K; cin >> n >> K; vector<int> D(n); vector<int> pos(n); for (int i = 0; i < n; i++) { cin >> D[i]; D[i]--; pos[D[i]] = i; } int ans = 0; for (int i = 0; i < n; i++) { if (D[i] != i) { int j = pos[i]; swap(D[i], D[j]); pos[D[i]] = j; pos[D[j]] = i; ans++; } } cout << (ans <= K && K - ans != 1 ? "YES" : "NO") << endl; }