結果
問題 |
No.1922 Separate and Attach
|
ユーザー |
|
提出日時 | 2023-04-25 23:52:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 1,642 ms |
コンパイル使用メモリ | 169,824 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-15 08:33:30 |
合計ジャッジ時間 | 4,624 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, ans = 0; cin >> n; vector<int> a(n), b(n), c(n); vector<bool> used(n); for(auto &&v : a) cin >> v, v--; for(int i = 0; i < n; i++){ cin >> b[i]; c[--b[i]] = i; } for(int i = 0; i < n; i++){ a[i] = c[a[i]]; if(a[i] == 0 || !used[a[i] - 1]){ ans++; } used[a[i]] = true; } if(__builtin_popcount(ans) != 1) ans <<= 1; cout << __lg(ans) << '\n'; }