結果
| 問題 | No.3726 Flawless Flow |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-19 14:58:15 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 4,827 bytes |
| 記録 | |
| コンパイル時間 | 4,447 ms |
| コンパイル使用メモリ | 344,324 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-09-19 14:58:25 |
| 合計ジャッジ時間 | 7,531 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 WA * 31 |
ソースコード
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll=long long;
using ld=long double;
using ull=unsigned long long;
using i128 = __int128_t;
#define vs vector<string>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep2(i,n) for(int i=n-1;i>=0;i--)
#define rep3(i,a,b) for(ll i=a;i<=ll(b);i++)
#define rep4(i,a,b) for(ll i=a;i>=ll(b);i--)
#define forv(i,V) for(const auto& i:V)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SIZE(x) int(x.size())
constexpr ll mod=998244353;
//constexpr ll mod=1000000007;
#define pi 3.14159265358979323
#define INF32 2147483647
#define INF64 9223372036854775807
#define faster ios::sync_with_stdio(false);std::cin.tie(nullptr)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rev reverse
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define prq priority_queue
#define lb lower_bound
#define ub upper_bound
#define popcnt __builtin_popcountll
#define TLE while(true);
#define RE assert(false);
#define MLE vector<vector<vector<long long>>> mle_mle(400,vector<vector<long long>>(1000,vector<long long>(1000)));
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
#define rall(n) (n).rbegin(),(n).rend()
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
template<typename T,typename U>
ostream &operator<<(ostream&os,const pair<T,U>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T,typename U>
istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<typename T>
ostream &operator<<(ostream&os,const vector<T>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;}
template<typename T>
istream &operator>>(istream&is,vector<T>&v){for(T &in:v){is>>in;}return is;}
void scan(){}
template<class Head,class... Tail>
void scan(Head&head,Tail&... tail){cin>>head;scan(tail...);}
template<class T>
void print(const T &t){cout<<t<<'\n';}
template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail){cout<<head<<' ';print(tail...);}
template<class... T>
void fin(const T &... a){print(a...);exit(0);}
ll max(int a,ll b){return max((ll)a,b);}
ll max(ll a,int b){return max((ll)b,a);}
ll min(int a,ll b){return min((ll)a,b);}
ll min(ll a,int b){return min((ll)b,a);}
//a以上b以下の個数
template<typename T>
ll RangeOK(ll a,ll b,vector<T> &v){
return max(ub(all(v),b)-lb(all(v),a),0);
}
template <typename T>
vector<T> compress(vector<T> &X) {
vector<T> vals = X;
sort(vals.begin(), vals.end());
vals.erase(unique(vals.begin(), vals.end()), vals.end());
for (int i = 0; i < (int)X.size(); i++) {
X[i] = lower_bound(vals.begin(), vals.end(), X[i]) - vals.begin();
}
return vals;
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;
void solve(){
INT(n);
vi a(n), b(n);
scan(a, b);
rep(i, n) a[i]--;
rep(i, n) b[i]--;
vi c(n);
rep(i, n) c[b[i]] = i;
vvi ans(n+1);
ans[0] = a;
ans[n] = b;
rep(i, n-1){
ans[i+1].resize(n);
vi ind(n);
rep(j, n) ind[j] = j;
sort(all(ind), [&](int p, int q){
return abs(p - c[ans[i][p]]) > abs(q - c[ans[i][q]]);
});
vi seen(n);
for(int j : ind){
if(c[ans[i][j]] < j){
if(seen[j-1] == 0 && seen[j] == 0){
ans[i+1][j] = ans[i][j-1];
ans[i+1][j-1] = ans[i][j];
seen[j-1] = seen[j] = 1;
}else if(seen[j] == 0){
ans[i+1][j] = ans[i][j];
}
}else if(c[ans[i][j]] > j){
if(seen[j+1] == 0 && seen[j] == 0){
ans[i+1][j] = ans[i][j+1];
ans[i+1][j+1] = ans[i][j];
seen[j+1] = seen[j] = 1;
}else if(seen[j] == 0){
ans[i+1][j] = ans[i][j];
}
}else if(seen[j] == 0){
ans[i+1][j] = ans[i][j];
}
}
}
rep(i, n+1){
rep(j, n) ans[i][j]++;
print(ans[i]);
}
}
int main(){
//INT(t);
int t = 1;
while(t--) solve();
}