結果
| 問題 |
No.1768 The frog in the well knows the great ocean.
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-26 23:52:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,125 bytes |
| コンパイル時間 | 4,180 ms |
| コンパイル使用メモリ | 248,692 KB |
| 実行使用メモリ | 22,692 KB |
| 最終ジャッジ日時 | 2024-06-29 19:08:54 |
| 合計ジャッジ時間 | 9,257 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 TLE * 1 -- * 21 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:41:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
41 | if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
| ^
main.cpp:42:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
42 | else for(auto[key,val]:M[u])M[v][key]+=val;
| ^
main.cpp:54:27: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
54 | if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
| ^
main.cpp:55:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
55 | else for(auto[key,val]:M[u])M[v][key]+=val;
| ^
main.cpp:59:27: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
59 | if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
| ^
main.cpp:60:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
60 | else for(auto[key,val]:M[u])M[v][key]+=val;
| ^
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef long double ld;
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,l,r) for(ll i=r-1;i>=l;i--)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define BS(A,x) binary_search(ALL(A),x)
#define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin())
#define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin())
#define COU(A,x) (UB(A,x)-LB(A,x))
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
//using mint=modint1000000007;
using mint=modint998244353;
void chmax(ll&a,ll b){a=max(a,b);}
void chmin(ll&a,ll b){a=min(a,b);}
signed main(){
int T,N;cin>>T;
vector<int>A(2e5),B(2e5);
set<int>S;
vector<map<int,int>>M(2e5);
while(T--){
scanf("%d",&N);
REP(i,N)scanf("%d",&A[i]);
REP(i,N)scanf("%d",&B[i]);
S.clear();REP(i,N)S.insert(A[i]);
bool ans=1;
REP(i,N)ans=ans&&count(ALL(S),B[i])&&A[i]<=B[i];
REP(i,N)M[i].clear();
REP(i,N)M[i][A[i]]++;
dsu D(N);
REP(i,N-1)if(B[i]==B[i+1]){
int u=D.leader(i),v=D.leader(i+1),r=D.merge(u,v);
if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
else for(auto[key,val]:M[u])M[v][key]+=val;
}
vector<vector<int>>X(N+1);
REP(i,N)if(i==0||B[i-1]!=B[i])X[B[i]].emplace_back(i);
RREP(v,N+1){
for(auto i:X[v]){
int l=i,r=N-1;
while(l!=r){
ll m=(l+r+1)/2;if(D.same(i,m))l=m;else r=m-1;
}
if(i&&B[i-1]>B[i]){
int u=D.leader(i-1),v=D.leader(i),r=D.merge(u,v);
if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
else for(auto[key,val]:M[u])M[v][key]+=val;
}
if(l<N-1&&B[l+1]>B[l]){
int u=D.leader(l+1),v=D.leader(l),r=D.merge(l,l+1);
if(r==u)for(auto[key,val]:M[v])M[u][key]+=val;
else for(auto[key,val]:M[u])M[v][key]+=val;
}
ans=ans&&M[D.leader(i)][v];
}
}
if(ans)printf("Yes\n");
else printf("No\n");
}
return 0;
}