提出 #75703329


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using mint=modint998244353;
void solve(){
    int n;
    cin>>n;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    int t=0;
    while(t<n){
        if(p[t]!=t+1)break;
        t++;
    }
    if(t==n-1)t++;
    mint ans=0;
    rep(i,t){
        ans+=n-i-1;
    }
    if(t==n)ans+=1;
    cout<<ans.val()<<endl;
}
int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t=1;
    cin>>t;
    while(t--)solve();
}

提出情報

提出日時
問題 B - Reverse Permutation
ユーザ itoito1234
言語 C++23 (GCC 15.2.0)
得点 400
コード長 594 Byte
結果 AC
実行時間 39 ms
メモリ 5380 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 1
AC × 15
セット名 テストケース
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 3432 KiB
01_handmade_00.txt AC 39 ms 3480 KiB
01_handmade_01.txt AC 18 ms 5344 KiB
01_handmade_02.txt AC 17 ms 5284 KiB
01_handmade_03.txt AC 14 ms 3568 KiB
02_random_00.txt AC 18 ms 5248 KiB
02_random_01.txt AC 18 ms 5380 KiB
02_random_02.txt AC 18 ms 5312 KiB
02_random_03.txt AC 19 ms 5312 KiB
02_random_04.txt AC 17 ms 5204 KiB
02_random_05.txt AC 18 ms 5320 KiB
02_random_06.txt AC 17 ms 5380 KiB
02_random_07.txt AC 17 ms 5204 KiB
02_random_08.txt AC 17 ms 5204 KiB
02_random_09.txt AC 17 ms 5288 KiB