結果

問題 No.2254 Reverse Only
ユーザー asaringoasaringo
提出日時 2023-03-24 22:24:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,028 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 218,052 KB
実行使用メモリ 26,268 KB
最終ジャッジ日時 2023-10-18 21:15:27
合計ジャッジ時間 13,356 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
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 WA -
testcase_09 AC 504 ms
25,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 467 ms
25,944 KB
testcase_13 WA -
testcase_14 AC 501 ms
26,268 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 495 ms
26,208 KB
testcase_19 WA -
testcase_20 AC 121 ms
14,328 KB
testcase_21 AC 121 ms
14,328 KB
testcase_22 AC 81 ms
14,328 KB
testcase_23 AC 98 ms
14,328 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 7 ms
4,520 KB
testcase_28 WA -
testcase_29 AC 188 ms
15,120 KB
testcase_30 WA -
testcase_31 AC 76 ms
9,632 KB
testcase_32 AC 90 ms
10,380 KB
testcase_33 AC 34 ms
7,088 KB
testcase_34 AC 263 ms
18,288 KB
testcase_35 AC 148 ms
13,288 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 55 ms
8,416 KB
testcase_39 WA -
testcase_40 AC 7 ms
4,504 KB
testcase_41 AC 128 ms
12,480 KB
testcase_42 AC 60 ms
8,832 KB
testcase_43 AC 273 ms
19,080 KB
testcase_44 AC 454 ms
24,888 KB
testcase_45 WA -
testcase_46 AC 6 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define repi(it,S) for(auto it = S.begin() ; it != S.end() ; it++)
#define pt(a) cout << a << endl
#define DEBUG(...) ; cout << #__VA_ARGS__ << endl ; for(auto x : {__VA_ARGS__}) cout << x << "  " ; cout << endl ;
#define DEBUG_LIST(...) cout << #__VA_ARGS__ << endl ; DEBUG_REP(__VA_ARGS__) ;
#define DEBUG_REP(V) cout << "{ " ; repi(itr,V) cout << *itr << ", " ; cout << "}" << endl ;
#define debug(a) cout << #a << " " << a << endl
#define all(a) a.begin(), a.end()
#define endl "\n"

int n, k;

int main(){
    fast_input_output
    cin >> n >> k;
    set<int> S, T;
    vector<int> A(n), B(n);
    map<int,int> mp;
    rep(i,n){
        cin >> A[i];
        mp[A[i]] = i;
        A[i] = i;
        S.insert(A[i]);
    }
    rep(i,n){
        cin >> B[i];
        B[i] = mp[B[i]];
        T.insert(B[i]);
    }
    if(S != T){
        cout << "No" << endl;
        return 0;
    }
    if(n > k + 1){
        cout << "Yes" << endl;
        return 0;
    }
    int k = -1;
    rep(i,n) if(B[i] == 0){
        k = i;
    }
    bool res = false;
    {
        bool ok = true;
        rep(i,n) if((B[i] + 1) % n != B[(i+1)%n]) ok = false;
        if(ok) res = true;
    }
    {
        bool ok = true;
        reverse(all(B));
        rep(i,n) if((B[i] + 1) % n != B[(i+1)%n]) ok = false;
        if(ok) res = true;
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0