結果
| 問題 | No.3726 Flawless Flow |
| コンテスト | |
| ユーザー |
Tehom
|
| 提出日時 | 2026-11-12 23:31:21 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,100 bytes |
| 記録 | |
| コンパイル時間 | 4,729 ms |
| コンパイル使用メモリ | 382,620 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-11-12 23:31:31 |
| 合計ジャッジ時間 | 8,617 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 48 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}
void solve(){
int n; cin >> n;
vector<int> a(n),b(n);
rep(i,0,n) cin >> a[i],a[i]--;
rep(i,0,n) cin >> b[i],b[i]--;
vector<vector<int>> ans(n+1);
vector<int> ord(n);
rep(i,0,n) ord[b[i]]=i;
ans[0]=a;
rep(i,0,n){
int j=0;
while(j<n-1){
if(ord[a[j]]>ord[a[j+1]]){
swap(a[j],a[j+1]);
j++;
}
j++;
}
ans[i+1]=a;
}
if(ans.back() != b) cout << "-1\n";
else{
rep(i,0,n+1){
rep(j,0,n) cout << ans[i][j]+1 << " "; cout << "\n";
}
}
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
// cin >> T;
rep(_,0,T){
solve();
}
}
Tehom