結果
| 問題 |
No.1922 Separate and Attach
|
| ユーザー |
Nachia
|
| 提出日時 | 2022-05-02 12:29:18 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 845 bytes |
| コンパイル時間 | 2,517 ms |
| コンパイル使用メモリ | 103,896 KB |
| 最終ジャッジ日時 | 2025-01-29 01:43:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 29 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
int main(){
int N; cin >> N;
vector<int> A(N);
{
vector<int> P(N);
rep(i,N){ cin >> P[i]; P[i]--; }
vector<int> Q(N);
rep(i,N){ cin >> Q[i]; Q[i]--; }
vector<int> invQ(N);
rep(i,N) invQ[Q[i]] = i;
rep(i,N) A[i] = invQ[P[i]];
}
int K = N;
rep(i,N-1) if(A[i] + 1 == A[i+1]) K--;
int ans = 0;
while((1 << ans) < K) ans++;
cout << ans << endl;
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia