結果

問題 No.1922 Separate and Attach
ユーザー t98slider
提出日時 2023-04-25 23:52:06
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 9 ms / 2,000 ms
+ 707µs
コード長 558 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,253 ms
コンパイル使用メモリ 187,348 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-09-23 01:37:52
合計ジャッジ時間 5,167 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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';
}
0