結果
問題 | No.2254 Reverse Only |
ユーザー |
|
提出日時 | 2023-03-24 22:24:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,028 bytes |
コンパイル時間 | 2,090 ms |
コンパイル使用メモリ | 219,060 KB |
実行使用メモリ | 26,112 KB |
最終ジャッジ日時 | 2024-09-18 17:17:38 |
合計ジャッジ時間 | 10,123 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,948 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | AC | 331 ms
25,984 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 330 ms
25,984 KB |
testcase_13 | WA | - |
testcase_14 | AC | 326 ms
25,984 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 313 ms
26,112 KB |
testcase_19 | WA | - |
testcase_20 | AC | 105 ms
14,208 KB |
testcase_21 | AC | 106 ms
14,208 KB |
testcase_22 | AC | 72 ms
14,208 KB |
testcase_23 | AC | 87 ms
14,208 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 7 ms
6,940 KB |
testcase_28 | WA | - |
testcase_29 | AC | 125 ms
15,232 KB |
testcase_30 | WA | - |
testcase_31 | AC | 55 ms
9,472 KB |
testcase_32 | AC | 69 ms
10,368 KB |
testcase_33 | AC | 29 ms
6,940 KB |
testcase_34 | AC | 197 ms
18,048 KB |
testcase_35 | AC | 102 ms
13,184 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 43 ms
8,320 KB |
testcase_39 | WA | - |
testcase_40 | AC | 7 ms
6,944 KB |
testcase_41 | AC | 93 ms
12,288 KB |
testcase_42 | AC | 48 ms
8,832 KB |
testcase_43 | AC | 186 ms
18,944 KB |
testcase_44 | AC | 301 ms
24,832 KB |
testcase_45 | WA | - |
testcase_46 | AC | 6 ms
6,940 KB |
ソースコード
#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; }