提出 #75701364
ソースコード 拡げる
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=5e5+10,P=998244353;
int T,n,p[N],s[N];
void solve(){
cin>>n;rep(i,1,n)cin>>p[i];
bool o=true;rep(i,1,n-1)o&=(p[i]<=p[i+1]);
if(o){ll ans=((1ll*n*(n-1))>>1)%P;ans=(ans+1)%P;cout<<ans<<"\n";return;}
rep(i,1,n)s[i]=0;s[n]=p[n];per(i,n-1,1)s[i]=min(p[i],s[i+1]);
int id=-1;rep(i,1,n-1)if(p[i]>s[i+1]){id=i;break;}
ll ans=0;if(id>1){ans=(((id-1)*((2ll*n-id))>>1)%P);}
cout<<ans<<"\n";
return;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>T;while(T--)solve();
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function 'void solve()':
./Main.cpp:3:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
3 | #define rep(i,l,r) for(int i=(l);i<=(r);++i)
| ^~~
./Main.cpp:14:9: note: in expansion of macro 'rep'
14 | rep(i,1,n)s[i]=0;s[n]=p[n];per(i,n-1,1)s[i]=min(p[i],s[i+1]);
| ^~~
./Main.cpp:14:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
14 | rep(i,1,n)s[i]=0;s[n]=p[n];per(i,n-1,1)s[i]=min(p[i],s[i+1]);
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
400 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt |
| All |
00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3452 KiB |
| 01_handmade_00.txt |
AC |
15 ms |
3692 KiB |
| 01_handmade_01.txt |
AC |
15 ms |
5580 KiB |
| 01_handmade_02.txt |
AC |
16 ms |
7480 KiB |
| 01_handmade_03.txt |
AC |
12 ms |
3584 KiB |
| 02_random_00.txt |
AC |
17 ms |
7448 KiB |
| 02_random_01.txt |
AC |
17 ms |
7424 KiB |
| 02_random_02.txt |
AC |
17 ms |
7424 KiB |
| 02_random_03.txt |
AC |
18 ms |
7512 KiB |
| 02_random_04.txt |
AC |
17 ms |
7404 KiB |
| 02_random_05.txt |
AC |
17 ms |
7424 KiB |
| 02_random_06.txt |
AC |
16 ms |
7568 KiB |
| 02_random_07.txt |
AC |
17 ms |
7532 KiB |
| 02_random_08.txt |
AC |
16 ms |
7656 KiB |
| 02_random_09.txt |
AC |
16 ms |
7572 KiB |