結果
問題 | No.1768 The frog in the well knows the great ocean. |
ユーザー | milanis48663220 |
提出日時 | 2021-11-27 00:11:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,054 bytes |
コンパイル時間 | 1,874 ms |
コンパイル使用メモリ | 126,380 KB |
実行使用メモリ | 24,332 KB |
最終ジャッジ日時 | 2023-09-12 06:07:24 |
合計ジャッジ時間 | 5,318 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 104 ms
13,744 KB |
testcase_13 | WA | - |
testcase_14 | AC | 103 ms
13,608 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 111 ms
23,436 KB |
testcase_20 | AC | 111 ms
23,440 KB |
testcase_21 | AC | 1 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 160 ms
24,096 KB |
testcase_27 | AC | 2 ms
4,376 KB |
ソースコード
#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 == -1) return b; return a; } T composition(T a, T 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(a); // for(int j = 0; j < n; j++) seg.set(j, 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); // cout << seg.prod(l, idx+1) << endl; // cout << idx << ' ' << l << ':' << r << endl; // for(int j = l; j < r; j++) seg.set(j, i); // for(int j = 0; j < n; j++) cout << seg.get(j) << ' '; // cout << endl; seg.apply(l, idx, i); seg.apply(idx, r, i); // for(int j = 0; j < n; j++) cout << seg.get(j) << ' '; // cout << endl; } // for(int j = 0; j < n; j++) cout << seg.get(j) << ' '; // cout << endl; 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(); }