結果
問題 | No.1768 The frog in the well knows the great ocean. |
ユーザー | TKTYI |
提出日時 | 2021-11-27 00:35:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,095 bytes |
コンパイル時間 | 3,763 ms |
コンパイル使用メモリ | 250,136 KB |
実行使用メモリ | 55,296 KB |
最終ジャッジ日時 | 2024-06-29 19:16:48 |
合計ジャッジ時間 | 9,641 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
18,968 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 | 256 ms
37,864 KB |
testcase_13 | WA | - |
testcase_14 | AC | 243 ms
37,796 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 261 ms
54,796 KB |
testcase_20 | AC | 249 ms
55,104 KB |
testcase_21 | AC | 9 ms
18,780 KB |
testcase_22 | AC | 7 ms
19,036 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 175 ms
41,732 KB |
testcase_26 | AC | 149 ms
41,716 KB |
testcase_27 | AC | 9 ms
19,124 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:43:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 43 | if(r==u)for(auto[key,val]:M[v])if(val)M[u][key]=1; | ^ main.cpp:44:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 44 | else for(auto[key,val]:M[u])if(val)M[v][key]=1; | ^ main.cpp:51:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 51 | if(r==u)for(auto[key,val]:M[v])if(val)M[u][key]=1; | ^ main.cpp:52:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 52 | else for(auto[key,val]:M[u])if(val)M[v][key]=1; | ^ main.cpp:56:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 56 | if(r==u)for(auto[key,val]:M[v])if(val)M[u][key]=1; | ^ main.cpp:57:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 57 | else for(auto[key,val]:M[u])if(val)M[v][key]=1; | ^
ソースコード
#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;bool ans; vector<int>A(2e5),B(2e5);set<int>S; vector<map<int,bool>>M(2e5); vector<vector<int>>X(2e5+1); 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]); ans=1;dsu D(N); REP(i,N+1)X[i].clear(); REP(i,N){ ans=ans&&S.count(B[i])&&A[i]<=B[i]; M[i].clear();M[i][A[i]]=1; if(i==0||B[i-1]!=B[i])X[B[i]].emplace_back(i); } 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])if(val)M[u][key]=1; else for(auto[key,val]:M[u])if(val)M[v][key]=1; } RREP(v,N+1)for(auto i:X[v]){ int l=i,r=N-1; while(l!=r){int 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])if(val)M[u][key]=1; else for(auto[key,val]:M[u])if(val)M[v][key]=1; } if(l<N-1&&B[l+1]>B[l]){ int u=D.leader(l+1),v=D.leader(l),r=D.merge(u,v); if(r==u)for(auto[key,val]:M[v])if(val)M[u][key]=1; else for(auto[key,val]:M[u])if(val)M[v][key]=1; } ans=ans&&M[D.leader(i)][v]; } if(ans)printf("Yes\n"); else printf("No\n"); } return 0; }