結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-07-09 01:05:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 463 bytes |
コンパイル時間 | 1,675 ms |
コンパイル使用メモリ | 166,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 20:25:16 |
合計ジャッジ時間 | 4,450 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 7 |
ソースコード
#include <bits/stdc++.h> #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define p(s) cout<<(s)<<endl typedef long long ll; using namespace std; int D[200100];//num of idx int a[200100];//idx of num int main(void){ int N; ll K; cin>>N>>K; REP(i,0,N) { cin>>D[i]; a[D[i]]=i; } ll cnt=0; REP(i,0,N){ if(D[i]!=i+1){ D[a[i+1]]=D[i]; D[i]=i+1; swap(a[D[i]],a[i]); cnt++; } } if(cnt<=K&&(K-cnt)%2==0) p("YES"); else p("NO"); return 0; }