結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2017-02-10 22:53:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,096 bytes |
| 記録 | |
| コンパイル時間 | 3,551 ms |
| コンパイル使用メモリ | 157,292 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-12-28 08:53:03 |
| 合計ジャッジ時間 | 3,797 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%lld%lld",&N,&K);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:26:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | rep(i,N)scanf("%lld",&D[i]),D[i]--;
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}
int N,K;
int D[222222];
int r[222222];
signed main(){
scanf("%lld%lld",&N,&K);
rep(i,N)scanf("%lld",&D[i]),D[i]--;
rep(i,N)r[D[i]]=i;
int latte=0;
bool flag=false;
rep(i,N){
if(D[i]==i)continue;
int t=D[i];
if(r[i]!=t)flag=true;
swap(D[i],D[r[i]]);
swap(r[i],r[t]);
latte++;
}
bool ok=true;
if(latte>K)ok=false;
else if(N==2&&(K-latte)%2)ok=false;
else if(!flag&&K-latte==1)ok=false;
if(ok)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
latte0119