結果
| 問題 | No.1768 The frog in the well knows the great ocean. | 
| コンテスト | |
| ユーザー |  milanis48663220 | 
| 提出日時 | 2021-11-27 00:37:24 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 366 ms / 3,000 ms | 
| コード長 | 2,592 bytes | 
| コンパイル時間 | 1,560 ms | 
| コンパイル使用メモリ | 125,720 KB | 
| 最終ジャッジ日時 | 2025-01-26 02:09:19 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 27 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/lazysegtree>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}
using T = int;
using S = int;
T INF = 1e9;
T e(){
    return -INF;
}
T op(T a, T b){
    return max(a, b);
}
T id(){
    return -1;
}
T mapping(S a, T b){
    if(a == id()) return b;
    return a;
}
T composition(T a, T b){
    if(a == id()) return b;
    return a;
}
using Seg = atcoder::lazy_segtree<T, op, e, S, mapping, composition, id>;
void solve(){
    int n; cin >> n;
    vector<int> a(n), b(n);
    vector<vector<int>> a_idx(n), b_idx(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        a_idx[a[i]].push_back(i);
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
        b[i]--;
        b_idx[b[i]].push_back(i);
    }
    Seg seg(n);
    for(int j = 0; j < n; j++) seg.apply(j, j+1, a[j]);
    for(int i = 0; i < n; i++){
        for(int idx: a_idx[i]){
            auto g = [&](T x){
                return x <= i;
            };
            int l = seg.min_left(idx+1, g);
            int r = seg.max_right(idx, g);   
            seg.apply(l, r, i);
        }
        for(int idx: b_idx[i]){
            if(seg.get(idx) != i){
                cout << "No" << endl;
                return;
            }
            seg.set(idx, INF);
        }
    }
    cout << "Yes" << endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int t; cin >> t;
    while(t--) solve();
}
            
            
            
        