結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2017-02-12 18:04:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 1,215 bytes |
| コンパイル時間 | 785 ms |
| コンパイル使用メモリ | 84,716 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-29 20:37:15 |
| 合計ジャッジ時間 | 2,874 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d%lld", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:51:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | scanf("%d", &ds[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- 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;
scanf("%d%lld", &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[ds[i]], es[ds[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;
}
tnakao0123