結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-28 00:25:17 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 825 bytes |
| 記録 | |
| コンパイル時間 | 853 ms |
| コンパイル使用メモリ | 101,936 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 21:15:22 |
| 合計ジャッジ時間 | 2,394 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | int x; scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <limits>
static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int main() {
ll n, k;
cin >> n >> k;
vector<int> v(n), u(n);
for (int i = 0; i < n; ++i) {
int x; scanf("%d", &x);
v[i] = x-1;
u[x-1] = i;
}
int ans = 0;
for (int i = 0; i < n; ++i) {
if(v[i] != i){
int j = u[i];
swap(v[i], v[j]);
u[v[i]] = i;
u[v[j]] = j;
ans++;
}
}
puts((ans&1) == (k&1) && ans <= k ? "YES" : "NO");
return 0;
}