結果

問題 No.2254 Reverse Only
ユーザー umezo
提出日時 2023-03-24 23:20:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 2,529 ms
コンパイル使用メモリ 198,348 KB
最終ジャッジ日時 2025-02-11 17:44:14
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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