結果
| 問題 |
No.1709 Indistinguishable by MEX
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-18 23:26:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 571 bytes |
| コンパイル時間 | 579 ms |
| コンパイル使用メモリ | 66,944 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 20:13:27 |
| 合計ジャッジ時間 | 3,501 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#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;
}