結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
Nasatame
|
| 提出日時 | 2017-02-10 23:19:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,584 bytes |
| コンパイル時間 | 1,043 ms |
| コンパイル使用メモリ | 87,964 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-29 04:44:34 |
| 合計ジャッジ時間 | 3,352 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 8 |
ソースコード
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
ll d[200010];
int main(void){
ll N,K,res = 0,total = 0,Found = 0;
cin >> N >> K;
for(int i = 0; i < N; i++){
cin >> d[i];
}
for(int i = 0; i < N; i++){
if(d[i] == i+1){
}else{
res++;
//cout << d[i] << " " << d[d[i]-1] << endl;
if(d[d[i]-1] == i+1 && d[d[i]-1] < d[i]){
Found++;
res-=2;
}else{
total++;
}
//cout << res << endl;
}
}
//cout << max(0LL,res-1)+Found << endl;
if(max(0LL,res-1)+Found <= K && (K - max(0LL,res-1)-Found) % 2 == 0){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
Nasatame