結果
問題 |
No.1922 Separate and Attach
|
ユーザー |
|
提出日時 | 2023-01-10 22:05:34 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,698 bytes |
コンパイル時間 | 3,350 ms |
コンパイル使用メモリ | 254,824 KB |
実行使用メモリ | 13,476 KB |
最終ジャッジ日時 | 2024-12-21 12:22:20 |
合計ジャッジ時間 | 6,503 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) #define rep3(i,m,n) for(int i=(m);i<(n);i++) #define foreach(x,a) for(auto& (x) : (a) ) #define endl '\n' #define dump(x) cout << #x << " = " << (x) << endl; #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl #define pb(a) push_back(a) #define sz(x) ((int)(x).size()) #define in(a,us) (us).find(a)!=(us).end() template<typename S> using Vec = vector<S>; template<typename S, typename T> using P = pair<S,T>; template<typename S, typename T, typename U> using Tpl = tuple<S,T,U>; using ll = long long; using ld = long double; using Pii = P<int, int>; using Pll = P<ll,ll>; using Tiii = Tpl<int,int,int>; using Tll = Tpl<ll,ll,ll>; using Vi = Vec<int>; using VVi = Vec<Vi>; template<typename S, typename T> using umap = unordered_map<S,T>; template<typename S> using uset = unordered_set<S>; using Graph = VVi; int main(){ cin.tie(0)->sync_with_stdio(0); int n; cin >> n; Vi a(n),b(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; umap<int,int> um; rep(i,n) um[a[i]] = i; Vi c(n); rep(i,n) c[i] = um[b[i]]; uset<int> s; rep(i,n){ if (in(c[i]-1,s)) { s.erase(s.find(c[i]-1)); s.insert(c[i]); } else { s.insert(c[i]); } } int sz = s.size(); int ans = 0; while (sz>1){ sz = (sz+1)/2; ans++; } cout << ans << endl; }