結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー kotatsugamekotatsugame
提出日時 2021-11-26 22:49:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,633 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 99,352 KB
実行使用メモリ 51,576 KB
最終ジャッジ日時 2023-09-12 05:48:38
合計ジャッジ時間 8,339 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 11 ms
4,376 KB
testcase_02 AC 11 ms
4,376 KB
testcase_03 AC 11 ms
4,380 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 293 ms
16,220 KB
testcase_07 AC 305 ms
25,352 KB
testcase_08 AC 283 ms
22,372 KB
testcase_09 AC 279 ms
15,964 KB
testcase_10 AC 293 ms
26,028 KB
testcase_11 AC 326 ms
27,036 KB
testcase_12 AC 296 ms
26,760 KB
testcase_13 AC 281 ms
27,112 KB
testcase_14 AC 299 ms
27,076 KB
testcase_15 AC 322 ms
26,584 KB
testcase_16 AC 368 ms
51,368 KB
testcase_17 AC 366 ms
51,576 KB
testcase_18 AC 379 ms
51,428 KB
testcase_19 AC 308 ms
48,120 KB
testcase_20 AC 355 ms
50,900 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 289 ms
51,360 KB
testcase_26 AC 260 ms
46,544 KB
testcase_27 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   37 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#include<vector>
#include<algorithm>
template<typename T>
struct rangefreq{
	int n;
	vector<vector<T> >dat;
	rangefreq(const vector<T>&v={})
	{
		n=1;
		while(n<v.size())n<<=1;
		dat.assign(2*n-1,{});
		for(int i=0;i<v.size();i++)dat[i+n-1].push_back(v[i]);
		for(int i=n-2;i>=0;i--)
		{
			dat[i].resize(dat[i*2+1].size()+dat[i*2+2].size());
			merge(dat[i*2+1].begin(),dat[i*2+1].end(),
				dat[i*2+2].begin(),dat[i*2+2].end(),
				dat[i].begin()
			);
		}
	}
	int query(int a,int b,T x,int k=0,int l=0,int r=-1)const//[a,b) count(*<x)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return 0;
		else if(a<=l&&r<=b)return lower_bound(dat[k].begin(),dat[k].end(),x)-dat[k].begin();
		else return query(a,b,x,k*2+1,l,(l+r)/2)+query(a,b,x,k*2+2,(l+r)/2,r);
	}
};
int T,N;
int A[2<<17];
main()
{
	cin>>T;
	vector<pair<int,int> >B;
	set<int>S;
	for(;T--;)
	{
		cin>>N;
		for(int i=0;i<N;i++)cin>>A[i];
		B.resize(N);
		for(int i=0;i<N;i++)
		{
			cin>>B[i].first;
			B[i].second=i;
		}
		sort(B.begin(),B.end());
		rangefreq<int>P(vector<int>(A,A+N));
		S.clear();
		S.insert(-1);
		S.insert(N);
		bool out=false;
		for(int i=0;i<B.size();)
		{
			auto it=S.lower_bound(B[i].second);
			int R=*it;
			it--;
			int L=*it+1;
			int j=i;
			int b=B[i].first;
			while(j<B.size()&&b==B[j].first&&B[j].second<R)
			{
				int id=B[j++].second;
				if(A[id]>b)out=true;
			}
			if(P.query(L,R,b+1)>P.query(L,R,b))
			{
				for(int k=i;k<j;k++)S.insert(B[k].second);
			}
			else
			{
				out=true;
			}
			if(out)break;
			i=j;
		}
		cout<<(out?"No\n":"Yes\n");
	}
}
0