結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー TKTYITKTYI
提出日時 2021-11-27 00:17:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,144 bytes
コンパイル時間 4,502 ms
コンパイル使用メモリ 250,756 KB
実行使用メモリ 48,780 KB
最終ジャッジ日時 2023-09-12 06:09:46
合計ジャッジ時間 10,487 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 293 ms
26,488 KB
testcase_12 WA -
testcase_13 AC 278 ms
26,152 KB
testcase_14 AC 264 ms
26,168 KB
testcase_15 AC 272 ms
26,476 KB
testcase_16 AC 309 ms
48,480 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 269 ms
48,536 KB
testcase_20 AC 272 ms
48,612 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 161 ms
41,404 KB
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:42:23: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   42 |       if(r==u)for(auto[key,val]:M[v])M[u][key]=M[u][key]||val;
      |                       ^
main.cpp:43:20: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   43 |       else for(auto[key,val]:M[u])M[v][key]=M[v][key]||val;
      |                    ^
main.cpp:51:27: 警告: 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])M[u][key]=M[u][key]||val;
      |                           ^
main.cpp:52:24: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   52 |           else for(auto[key,val]:M[u])M[v][key]=M[v][key]||val;
      |                        ^
main.cpp:56:27: 警告: 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])M[u][key]=M[u][key]||val;
      |                           ^
main.cpp:57:24: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   57 |           else for(auto[key,val]:M[u])M[v][key]=M[v][key]||val;
      |                        ^

ソースコード

diff #

#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;
  while(T--){
    scanf("%d",&N);
    vector<int>A(N),B(N);
    REP(i,N)scanf("%d",&A[i]);
    REP(i,N)scanf("%d",&B[i]);
    set<int>S;REP(i,N)S.insert(A[i]);
    bool ans=1;dsu D(N);
    vector<map<int,bool>>M(N);
    vector<vector<int>>X(N+1);
    REP(i,N){
      ans=ans&&S.count(B[i])&&A[i]<=B[i];
      M[i].clear();M[i][A[i]]=1;X[i+1].clear();
      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])M[u][key]=M[u][key]||val;
      else for(auto[key,val]:M[u])M[v][key]=M[v][key]||val;
    }
    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])M[u][key]=M[u][key]||val;
          else for(auto[key,val]:M[u])M[v][key]=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(u,v);
          if(r==u)for(auto[key,val]:M[v])M[u][key]=M[u][key]||val;
          else for(auto[key,val]:M[u])M[v][key]=M[v][key]||val;
        }
        ans=ans&&M[D.leader(i)][v];
      }
    }
    if(ans)printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}
0