結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-12 17:54:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,197 bytes |
コンパイル時間 | 1,034 ms |
コンパイル使用メモリ | 83,384 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 16:51:15 |
合計ジャッジ時間 | 2,341 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: 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; cin >> 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[i], es[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; }