結果
問題 |
No.1922 Separate and Attach
|
ユーザー |
|
提出日時 | 2023-01-10 16:42:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 350 bytes |
コンパイル時間 | 2,408 ms |
コンパイル使用メモリ | 195,768 KB |
最終ジャッジ日時 | 2025-02-10 01:34:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int>p(n),q(n); for(auto&e:p)cin>>e,--e; for(auto&e:q)cin>>e,--e; vector<int>iq(n); for(int i=0;i<n;++i)iq[q[i]]=i; for(int i=0;i<n;++i)p[i]=iq[p[i]],q[p[i]]=i; int num=0; for(int i=0;i<n-1;++i)num+=q[i]>q[i+1]; int ans=0; while(1<<ans<=num)++ans; cout<<ans<<endl; }