結果

問題 No.1804 Intersection of LIS
ユーザー 沙耶花沙耶花
提出日時 2022-01-07 22:02:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 1,128 bytes
コンパイル時間 4,960 ms
コンパイル使用メモリ 258,820 KB
実行使用メモリ 24,164 KB
最終ジャッジ日時 2024-04-26 18:41:39
合計ジャッジ時間 10,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 260 ms
23,104 KB
testcase_04 AC 273 ms
23,260 KB
testcase_05 AC 245 ms
23,136 KB
testcase_06 AC 234 ms
23,136 KB
testcase_07 AC 233 ms
23,264 KB
testcase_08 AC 238 ms
23,136 KB
testcase_09 AC 236 ms
23,136 KB
testcase_10 AC 244 ms
23,140 KB
testcase_11 AC 233 ms
23,136 KB
testcase_12 AC 235 ms
23,136 KB
testcase_13 AC 233 ms
23,132 KB
testcase_14 AC 240 ms
23,260 KB
testcase_15 AC 231 ms
23,136 KB
testcase_16 AC 231 ms
23,388 KB
testcase_17 AC 234 ms
23,132 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 208 ms
24,164 KB
testcase_36 AC 211 ms
24,076 KB
testcase_37 AC 229 ms
23,136 KB
testcase_38 AC 233 ms
23,132 KB
testcase_39 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001

using P = pair<int,mint>;

P op(P a,P b){
	if(a.first==b.first){
		return make_pair(a.first,a.second+b.second);
	}
	if(a.first>b.first)return a;
	return b;
}

P e(){
	return make_pair(0,0);
}

int main(){
	
	int n;
	cin>>n;
	
	vector<int> p(n);
	rep(i,n){
		cin>>p[i];
		p[i]--;
	}
	
	segtree<P,op,e> s0(n),s1(n);
	
	rep(i,n){
		auto ret = s0.prod(0,p[i]);
		if(ret==e()){
			ret.first = 1;
			ret.second = 1;
		}
		else ret.first++;
		s0.set(p[i],ret);
	}
	
	for(int i=n-1;i>=0;i--){
		auto ret = s1.prod(p[i]+1,n);
		if(ret==e()){
			ret.first = 1;
			ret.second = 1;
		}
		else ret.first++;
		s1.set(p[i],ret);
	}
	
	vector<int> ans;
	rep(i,n){
		auto r0 = s0.get(p[i]);
		auto r1 = s1.get(p[i]);
		r0.first += r1.first - 1;
		r0.second *= r1.second;
		if(s0.all_prod()==r0)ans.push_back(p[i]);
	}
	
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		if(i!=0)cout<<' ';
		cout<<ans[i]+1;
	}
	cout<<endl;
		
	
	return 0;
}
0