結果
| 問題 | No.3726 Flawless Flow |
| コンテスト | |
| ユーザー |
てんぷら
|
| 提出日時 | 2026-09-19 13:57:44 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 8 ms / 2,000 ms |
| + 954µs | |
| コード長 | 1,191 bytes |
| 記録 | |
| コンパイル時間 | 2,356 ms |
| コンパイル使用メモリ | 335,384 KB |
| 実行使用メモリ | 10,044 KB |
| 最終ジャッジ日時 | 2026-09-19 13:58:00 |
| 合計ジャッジ時間 | 5,263 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 59 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef TEMPURA
#else
#define debug(...) ((void)0)
#define msg(...) ((void)0)
#endif
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
template <class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
// #include <atcoder/modint>
// using mint = atcoder::modint998244353;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> a(n), b(n);
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
vector<int> pos(n + 1);
rep(i, n) pos[b[i]] = i;
rep(i, n) cout << a[i] << " \n"[i + 1 == n];
rep(i, n) {
for(int j = i % 2; j + 1 < n; j += 2) {
if(pos[a[j]] > pos[a[j + 1]]) {
swap(a[j], a[j + 1]);
}
}
rep(j, n) cout << a[j] << " \n"[j + 1 == n];
}
return 0;
}
てんぷら