結果

問題 No.482 あなたの名は
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-02-10 22:45:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,399 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 87,668 KB
実行使用メモリ 7,880 KB
最終ジャッジ日時 2023-08-27 22:49:09
合計ジャッジ時間 2,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,924 KB
testcase_01 AC 3 ms
4,904 KB
testcase_02 AC 3 ms
5,084 KB
testcase_03 WA -
testcase_04 AC 3 ms
4,948 KB
testcase_05 AC 3 ms
4,852 KB
testcase_06 AC 3 ms
4,948 KB
testcase_07 AC 3 ms
4,936 KB
testcase_08 AC 3 ms
5,100 KB
testcase_09 AC 3 ms
5,088 KB
testcase_10 AC 3 ms
4,896 KB
testcase_11 AC 3 ms
5,008 KB
testcase_12 AC 3 ms
4,924 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 63 ms
7,752 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 62 ms
7,756 KB
testcase_19 AC 62 ms
7,732 KB
testcase_20 AC 63 ms
7,684 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 62 ms
7,732 KB
testcase_25 AC 62 ms
7,648 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 60 ms
7,676 KB
testcase_30 AC 2 ms
4,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200010];
ll dd[200010];

int main() {
  ll n,k;
  cin>>n>>k;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    a--;
    v.pb(a);
  }
  rep(i,0,v.sz){
    d[v[i]] = i; 
  }
  clr(dd,-1);
  rep(i,0,n){
    if(d[i]==i){
      dd[i]=0;
    }
    if(dd[i]==1)continue;
    if(d[d[i]]==i){
      dd[i] = 1;
      dd[d[i]] = 1;
    }
  }
  ll c1 = 0;
  ll c2 = 0;
  rep(i,0,n){
    if(dd[i]==1){
      c1++;
    }
    if(dd[i]==-1){
      c2++;
    }
  }
  ll ans = c1/2+max(0LL,c2-1);
  if(ans>k){
    cout << "NO" << endl;
  }
  else if((k-ans)%2==1){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
  return 0;
}
0