結果

問題 No.1709 Indistinguishable by MEX
ユーザー mortalmortal
提出日時 2021-12-23 14:54:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 167,244 KB
実行使用メモリ 5,264 KB
最終ジャッジ日時 2023-10-17 15:38:30
合計ジャッジ時間 5,247 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 52 ms
4,984 KB
testcase_09 AC 43 ms
4,748 KB
testcase_10 AC 40 ms
4,700 KB
testcase_11 AC 32 ms
4,516 KB
testcase_12 AC 32 ms
4,496 KB
testcase_13 AC 46 ms
4,876 KB
testcase_14 AC 43 ms
4,784 KB
testcase_15 AC 46 ms
4,848 KB
testcase_16 AC 60 ms
5,200 KB
testcase_17 AC 56 ms
5,084 KB
testcase_18 AC 67 ms
5,264 KB
testcase_19 AC 65 ms
5,264 KB
testcase_20 AC 64 ms
5,264 KB
testcase_21 AC 63 ms
5,264 KB
testcase_22 AC 63 ms
5,264 KB
testcase_23 AC 63 ms
5,264 KB
testcase_24 AC 63 ms
5,264 KB
testcase_25 AC 63 ms
5,264 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 34 ms
4,568 KB
testcase_28 AC 31 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int


int main(){
	int T=1;
	//cin>>T;
	assert(1 <= T && T <= 10);
	while(T--){
		int n,i;
		cin>>n;
		int a[n];
		int pos[n];
		for(i=0;i<n;i++){
			cin>>a[i];
			pos[a[i]]=i;
		}
		int l=pos[0];
		int r=pos[0];
		ll ans=1;
		for(i=1;i<n;i++){
			if(pos[i]<r&&pos[i]>l){
				ll z=(r-l+1)-i;
				ans=(ans*z)%mod;
			}
			else
			{
				l=min(l,pos[i]);
				r=max(r,pos[i]);
			}
		}
		cout<<ans<<"\n";



	}

	

}
0