結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー kotatsugamekotatsugame
提出日時 2021-11-26 23:03:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,773 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 102,592 KB
実行使用メモリ 53,156 KB
最終ジャッジ日時 2023-09-12 05:52:16
合計ジャッジ時間 11,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 15 ms
4,380 KB
testcase_02 AC 15 ms
4,380 KB
testcase_03 AC 15 ms
4,380 KB
testcase_04 AC 15 ms
4,376 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 431 ms
19,756 KB
testcase_07 AC 461 ms
26,060 KB
testcase_08 AC 410 ms
22,712 KB
testcase_09 AC 413 ms
16,668 KB
testcase_10 AC 442 ms
27,336 KB
testcase_11 AC 479 ms
27,576 KB
testcase_12 AC 479 ms
27,712 KB
testcase_13 AC 491 ms
27,720 KB
testcase_14 AC 489 ms
27,684 KB
testcase_15 AC 487 ms
27,576 KB
testcase_16 AC 557 ms
53,156 KB
testcase_17 AC 571 ms
53,004 KB
testcase_18 AC 569 ms
52,956 KB
testcase_19 AC 566 ms
53,012 KB
testcase_20 AC 569 ms
52,820 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 443 ms
53,008 KB
testcase_26 AC 442 ms
52,884 KB
testcase_27 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:36:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   36 | 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;
main()
{
	cin>>T;
	vector<pair<int,int> >A,B;
	vector<int>PA;
	multiset<int>S;
	for(;T--;)
	{
		cin>>N;
		A.resize(N);
		PA.resize(N);
		for(int i=0;i<N;i++)
		{
			cin>>PA[i];
			A[i]=make_pair(PA[i],i);
		}
		B.resize(N);
		for(int i=0;i<N;i++)
		{
			cin>>B[i].first;
			B[i].second=i;
		}
		sort(A.begin(),A.end());
		sort(B.begin(),B.end());
		rangefreq<int>P(PA);
		S.clear();
		S.insert(-1);
		S.insert(N);
		for(int i=0;i<N;i++)S.insert(i);
		bool out=false;
		int ai=0;
		for(int i=0;i<B.size();)
		{
			int b=B[i].first;
			int j=i;
			while(j<B.size()&&b==B[j].first)j++;
			while(ai<A.size()&&A[ai].first<=b)
			{
				S.erase(S.find(A[ai++].second));
			}
			for(int k=i;k<j;k++)
			{
				auto it=S.lower_bound(B[k].second);
				int R=*it;
				it--;
				int L=*it+1;
				if(P.query(L,R,b+1)==P.query(L,R,b))out=true;
			}
			while(i<j)
			{
				S.insert(B[i++].second);
			}
		}
		cout<<(out?"No\n":"Yes\n");
	}
}
0