結果
| 問題 | No.2254 Reverse Only |
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2023-03-24 21:45:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 152 ms / 2,000 ms |
| コード長 | 1,302 bytes |
| コンパイル時間 | 2,527 ms |
| コンパイル使用メモリ | 190,076 KB |
| 実行使用メモリ | 12,700 KB |
| 最終ジャッジ日時 | 2024-09-18 16:57:08 |
| 合計ジャッジ時間 | 7,936 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/string>
using namespace std;
int main(){
int N, k;
cin >> N >> k;
vector<int> A(N);
for (int i = 0; i < N; i++){
cin >> A[i];
}
vector<int> B(N);
for (int i = 0; i < N; i++){
cin >> B[i];
}
if (k > N){
if (A == B){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else if (k == N){
vector<int> A2 = A;
reverse(A2.begin(), A2.end());
if (A == B || A2 == B){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else if (k == N - 1){
vector<int> C = B;
for (int i = 0; i < N; i++){
C.push_back(A[i]);
}
for (int i = 0; i < N; i++){
C.push_back(A[i]);
}
C.push_back(-1);
for (int i = N - 1; i >= 0; i--){
C.push_back(A[i]);
}
for (int i = N - 1; i >= 0; i--){
C.push_back(A[i]);
}
vector<int> Z = atcoder::z_algorithm(C);
bool ok = false;
for (int i = N; i <= N * 5; i++){
if (Z[i] >= N){
ok = true;
}
}
if (ok){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
sort(A.begin(), A.end());
sort(B.begin(), B.end());
if (A == B){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
SSRS