結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_09 WA -
testcase_10 AC 154 ms
23,464 KB
testcase_11 WA -
testcase_12 AC 235 ms
23,464 KB
testcase_13 AC 240 ms
23,464 KB
testcase_14 AC 259 ms
23,464 KB
testcase_15 AC 278 ms
23,464 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 249 ms
23,464 KB
testcase_19 WA -
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 WA -
testcase_29 AC 80 ms
12,640 KB
testcase_30 WA -
testcase_31 AC 35 ms
7,888 KB
testcase_32 AC 41 ms
8,428 KB
testcase_33 AC 19 ms
5,996 KB
testcase_34 AC 126 ms
15,280 KB
testcase_35 AC 71 ms
11,116 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 27 ms
6,924 KB
testcase_39 WA -
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 56 ms
10,264 KB
testcase_42 AC 30 ms
7,228 KB
testcase_43 AC 122 ms
16,072 KB
testcase_44 AC 221 ms
22,144 KB
testcase_45 WA -
testcase_46 AC 4 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<<"No"<<endl;
    return 0;
  }
  cout<<1<<endl;
  
  
  
  
   
  return 0;
}
0