結果
| 問題 | No.3726 Flawless Flow |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-07-01 12:28:30 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 9 ms / 2,000 ms |
| + 152µs | |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 2,114 ms |
| コンパイル使用メモリ | 333,264 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-19 12:31:23 |
| 合計ジャッジ時間 | 5,841 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 59 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n), b(n), rankInB(n + 1);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> b[i];
rankInB[b[i]] = i;
}
vector<int> row = a;
auto printRow = [&]() {
for (int i = 0; i < n; i++) {
if (i > 0) {
cout << ' ';
}
cout << row[i];
}
cout << '\n';
};
printRow();
for (int phase = 0; phase < n; phase++) {
int start = phase % 2;
for (int i = start; i + 1 < n; i += 2) {
if (rankInB[row[i]] > rankInB[row[i + 1]]) {
swap(row[i], row[i + 1]);
}
}
printRow();
}
return 0;
}