結果
問題 |
No.2254 Reverse Only
|
ユーザー |
![]() |
提出日時 | 2023-03-24 22:53:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,256 bytes |
コンパイル時間 | 2,354 ms |
コンパイル使用メモリ | 200,108 KB |
最終ジャッジ日時 | 2025-02-11 17:37:15 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 42 WA * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i,n) for(ll i=0;i<(n);++i) #define OREP(i,n) for(ll i=1;i<=(n);++i) #define RREP(i,n) for(ll i=(n)-1;i>=0;--i) #define ALL(v) (v).begin(), (v).end() #define GOODBYE do { cout << "-1" << endl; return 0; } while (false) #define MM <<" "<< #define Endl endl #define debug true #define debug2 false int main(void){ //cin.tie(nullptr); //ios::sync_with_stdio(false); ll N,K; cin >> N >> K; vector<ll> A(N),B(N); REP(i,N){cin >> A[i];} REP(i,N){cin >> B[i];} vector<ll> sA = A,sB = B; sort(ALL(sA)); sort(ALL(sB)); if(sA!=sB){ cout << "No" << endl; return 0; } vector<ll> rB = B;reverse(ALL(rB)); if(K<=N-2){ cout << "Yes" << endl; return 0; } if(K==N){ if(A==B || A==rB){ cout << "Yes" << endl; }else{ cout << "No" << endl; } return 0; } if(K>N){ if(A==B){ cout << "Yes" << endl; }else{ cout << "No" << endl; } return 0; } ll k = -1; REP(i,N){ if(A[i]==B[0]){ k = i; } } vector<ll> cA = A; REP(i,N){ cA[i] = A[(i+k)%N]; } if(cA == B){ cout << "Yes" << endl; return 0; } /*REP(i,N){cout << A[i] << " ";}cout << endl; REP(i,N){cout << cA[i] << " ";}cout << endl; REP(i,N){cout << rB[i] << " ";}cout << endl;*/ k = -1; REP(i,N){ if(A[i]==rB[0]){ k = i; } } REP(i,N){ cA[i] = A[(i+k)%N]; } if(cA == rB){ cout << "Yes" << endl; return 0; } cout << "No" << endl; /*ll N = 5,K = 3; cin >> N >> K; map<vector<ll>,ll> ind; ll now = 0; vector<ll> d(N); REP(i,N){d[i] = i;} do{ ind[d] = now; now++; }while(next_permutation(ALL(d))); queue<vector<ll>> que; vector<bool> enqueued(now,false); REP(i,N){d[i] = i;} que.push(d); enqueued[ind[d]] = true; while(!que.empty()){ vector<ll> t = que.front(); que.pop(); for(ll l=0;l<N;l++){ for(ll r=l;r<N;r++){ if((r-l+1)<K)continue; vector<ll> R = t; for(ll e=l;e<=r;e++){ R[e] = t[l+r-e]; } if(!enqueued[ind[R]]){ que.push(R); enqueued[ind[R]] = true; } } } } REP(i,N){d[i] = i;} ll c = 0; do{ if(enqueued[ind[d]]){ REP(i,N){ cout << d[i] << " "; } cout << endl; c++; } }while(next_permutation(ALL(d))); cout << c MM (now-c) << endl;*/ return 0; }