結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-03-10 14:56:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 1,697 ms |
コンパイル使用メモリ | 167,164 KB |
実行使用メモリ | 20,124 KB |
最終ジャッジ日時 | 2024-06-24 07:48:40 |
合計ジャッジ時間 | 7,580 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 1 RE * 11 TLE * 1 -- * 15 |
コンパイルメッセージ
main.cpp: In function ‘int swap(int*, int*)’: main.cpp:13:1: warning: no return statement in function returning non-void [-Wreturn-type] 13 | } | ^
ソースコード
#include<bits/stdc++.h> using namespace std; #define INF 1000000000 #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) typedef long long LL; int N,K; int A[300000]; map<int ,int>m; int swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } int main(){ cin>>N>>K; REP(i,N){ cin>>A[i]; m[A[i]]=i; } REP(i,N){ if(A[i]!=i+1){ int b=m[i+1]; swap(&A[i],&A[b]); m[A[i]]=b; m[A[b]]=i; K--; } } /*REP(i,N){ cout<<A[i]<<endl; }*/ if(K<0){ cout<<"NO"<<endl; }else{ if(K%2==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } return 0; }