結果
問題 |
No.1922 Separate and Attach
|
ユーザー |
![]() |
提出日時 | 2022-05-04 21:58:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 41,856 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 00:36:23 |
合計ジャッジ時間 | 3,465 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
/* -*- coding: utf-8 -*- * * 1922.cc: No.1922 Separate and Attach - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ /* global variables */ int ps[MAX_N], rqs[MAX_N], as[MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", ps + i), ps[i]--; for (int i = 0; i < n; i++) { int qi; scanf("%d", &qi), qi--; rqs[qi] = i; } for (int i = 0; i < n; i++) as[rqs[ps[i]]] = i; //for (int i = 0; i < n; i++) printf("%d ", as[i]); putchar('\n'); int l = 1; for (int i = 0; i + 1 < n; i++) if (as[i] > as[i + 1]) l++; int c = 0; while (l > 1) { l = (l + 1) / 2; c++; } printf("%d\n", c); return 0; }