結果

問題 No.2254 Reverse Only
ユーザー 0214sh70214sh7
提出日時 2023-03-24 22:48:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,783 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 205,888 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2023-10-18 21:22:36
合計ジャッジ時間 7,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 1 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 119 ms
8,080 KB
testcase_09 AC 125 ms
9,664 KB
testcase_10 AC 125 ms
8,080 KB
testcase_11 AC 119 ms
8,080 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 125 ms
9,664 KB
testcase_15 AC 119 ms
8,080 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 125 ms
8,080 KB
testcase_20 AC 131 ms
9,664 KB
testcase_21 AC 131 ms
9,664 KB
testcase_22 AC 68 ms
9,664 KB
testcase_23 AC 131 ms
9,664 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 6 ms
4,348 KB
testcase_28 AC 27 ms
4,384 KB
testcase_29 AC 58 ms
6,232 KB
testcase_30 AC 49 ms
5,176 KB
testcase_31 AC 30 ms
4,648 KB
testcase_32 AC 34 ms
4,912 KB
testcase_33 AC 17 ms
4,348 KB
testcase_34 AC 74 ms
7,024 KB
testcase_35 AC 49 ms
5,704 KB
testcase_36 AC 101 ms
7,288 KB
testcase_37 AC 106 ms
7,552 KB
testcase_38 AC 25 ms
4,384 KB
testcase_39 AC 93 ms
7,024 KB
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 44 ms
5,440 KB
testcase_42 AC 26 ms
4,648 KB
testcase_43 AC 81 ms
7,288 KB
testcase_44 AC 117 ms
9,136 KB
testcase_45 AC 69 ms
5,968 KB
testcase_46 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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> 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;
    }
    
    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;
    }
    
    
    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;
}
0