結果
問題 | No.1707 Simple Range Reverse Problem |
ユーザー |
![]() |
提出日時 | 2021-10-03 15:07:26 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 843 ms |
コンパイル使用メモリ | 96,348 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 17:08:20 |
合計ジャッジ時間 | 1,437 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool solve() { int N; cin >> N; vector<int> A(N * 2); for (auto &x : A) cin >> x; vector<int> X(N * 2); for (int i = 0; i < N; ++i) X[i] = X[N + i] = i + 1; if (A == X) return true; for (int t = 0; t < N; ++t) { std::reverse(X.begin() + t + 1, X.begin() + t + N); if (X == A) return true; std::reverse(X.begin() + t + 1, X.begin() + t + N); } return false; } int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int T; cin >> T; while (T--) cout << (solve() ? "Yes" : "No") << '\n'; }