結果

問題 No.2254 Reverse Only
ユーザー umezoumezo
提出日時 2023-03-24 23:20:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 207,348 KB
実行使用メモリ 23,436 KB
最終ジャッジ日時 2023-10-18 21:35:20
合計ジャッジ時間 9,956 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 278 ms
23,436 KB
testcase_09 WA -
testcase_10 AC 155 ms
23,436 KB
testcase_11 AC 277 ms
23,436 KB
testcase_12 AC 244 ms
23,436 KB
testcase_13 AC 249 ms
23,436 KB
testcase_14 AC 255 ms
23,436 KB
testcase_15 AC 270 ms
23,436 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 250 ms
23,436 KB
testcase_19 AC 216 ms
23,436 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 5 ms
4,348 KB
testcase_28 AC 36 ms
7,596 KB
testcase_29 AC 91 ms
12,612 KB
testcase_30 AC 78 ms
11,292 KB
testcase_31 AC 35 ms
7,860 KB
testcase_32 AC 41 ms
8,400 KB
testcase_33 AC 19 ms
5,968 KB
testcase_34 AC 116 ms
15,252 KB
testcase_35 AC 65 ms
11,088 KB
testcase_36 AC 206 ms
20,268 KB
testcase_37 AC 229 ms
21,060 KB
testcase_38 AC 28 ms
6,896 KB
testcase_39 AC 196 ms
18,948 KB
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 58 ms
10,236 KB
testcase_42 AC 31 ms
7,200 KB
testcase_43 AC 129 ms
16,044 KB
testcase_44 AC 235 ms
22,116 KB
testcase_45 AC 126 ms
14,988 KB
testcase_46 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
 
  int n,k;
  cin>>n>>k;
  vector<int> A(n),B(n);
  multiset<int> c,d;
  bool b=true;
  rep(i,n){
    cin>>A[i];
    c.insert(A[i]);
  }
  rep(i,n){
    cin>>B[i];
    if(B[i]!=A[i]) b=false;
    d.insert(B[i]);
  }
  
  if(b){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(k>n || c!=d){
    cout<<"No"<<endl;
    return 0;
  }
  if(k==n){
    reverse(ALL(B));
    b=true;
    rep(i,n){
      if(A[i]!=B[i]) b=false;
      if(b) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
    }
  }
  if(k<n-1){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<1<<endl;
  
  
  
  
   
  return 0;
}
0