結果

問題 No.1709 Indistinguishable by MEX
ユーザー kotatsugamekotatsugame
提出日時 2021-10-18 23:26:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 67,440 KB
実行使用メモリ 5,380 KB
最終ジャッジ日時 2023-10-20 00:19:59
合計ジャッジ時間 3,916 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 57 ms
5,068 KB
testcase_09 AC 43 ms
4,804 KB
testcase_10 AC 41 ms
4,752 KB
testcase_11 AC 33 ms
4,544 KB
testcase_12 AC 32 ms
4,516 KB
testcase_13 AC 48 ms
4,948 KB
testcase_14 AC 43 ms
4,840 KB
testcase_15 AC 46 ms
4,916 KB
testcase_16 AC 62 ms
5,312 KB
testcase_17 AC 57 ms
5,184 KB
testcase_18 AC 66 ms
5,380 KB
testcase_19 AC 65 ms
5,380 KB
testcase_20 AC 66 ms
5,380 KB
testcase_21 AC 63 ms
5,380 KB
testcase_22 AC 63 ms
5,380 KB
testcase_23 AC 64 ms
5,380 KB
testcase_24 AC 64 ms
5,380 KB
testcase_25 AC 64 ms
5,380 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 35 ms
4,600 KB
testcase_28 AC 31 ms
4,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
int P[2<<17],inv[2<<17];
bool vis[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		inv[P[i]]=i;
	}
	int pc=1;
	int l=inv[0],r=inv[0];
	int rest=0;
	mint ans=1;
	while(pc<N)
	{
		int id=inv[pc];
		while(id<l)
		{
			l--;
			rest++;
			vis[P[l]]=true;
		}
		while(r<id)
		{
			r++;
			rest++;
			vis[P[r]]=true;
		}
		pc++;
		rest--;
		while(pc<N&&vis[pc])
		{
			pc++;
			ans=ans*rest--;
		}
	}
	while(rest)ans*=rest--;
	cout<<ans.val()<<endl;
}
0