QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625275#9353. Interesting Permutation53DawnsWA 56ms4328kbC++231.6kb2024-10-09 18:21:442024-10-09 18:21:45

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 18:21:45]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:4328kb
  • [2024-10-09 18:21:44]
  • 提交

answer

#include<bits/stdc++.h>
// #pragma GCC optimize (1)
// #pragma GCC optimize (2)
// #pragma GCC optimize (3)
#define deg(a) cout<<#a<<'='<<a<<"\n"
#define all(a) a.begin(),a.end()
#define lowbit(x)  ((x)&(-x))
#define find1(x)  (__builtin_popcount(x))
#define pll pair<int,int>
#define int long long   
#define endl '\n'
#define ff first
#define ss second
#define lc p<<1
#define rc p<<1|1
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
const int M = 1e6 + 10;
const int mod1 = 998244353;
const int mod2 = 1e9+7;
const int INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-10;
int a[N] = {0}; 
void solve(){
     int n;
     cin >> n;
     int ff = 0;
     int ans = 1;
     map<int,int>mp;
     for(int i = 1 ; i <= n ; i++) {
         cin >> a[i];
         if(a[i] >= n) {
            ff = 1;
         }
     }
     if(a[1] != 0 || a[n] != n - 1) ff = 1;
     for(int i = 1 ; i < n ; i++) {
        if(a[i+1] < a[i] || a[i] + 1 < i) {
            ff = 1;
        }
     }
     if(ff) {
        cout << 0 << endl;
        return;
     }else {
        int sz = 1;
        for(int i = 2 ; i <= n ; i++) {
            int x = a[i] + 1;
            if(x > sz) {
                ans *= 2;
                ans %= mod2;
            }else {
                ans = ans * (sz - 2) % mod2;
            }
            sz = x ;
        }
     }
     cout << ans << endl;


} 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int kk = 1;
    cin >> kk;
    while(kk--) {
        solve();
    }
    return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3768kb

input:

3
3
0 2 2
3
0 1 2
3
0 2 3

output:

2
4
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 56ms
memory: 4328kb

input:

10039
14
5 6 7 8 9 10 11 12 13 13 13 13 13 13
14
0 5 6 7 8 9 10 11 12 13 14 14 14 14
1
1
14
0 5 4 8 9 10 11 12 13 13 13 13 13 13
45
0 1 1 2 2 3 5 5 6 6 8 9 11 13 15 17 18 18 20 22 22 24 26 26 26 26 27 27 27 28 30 32 32 33 34 34 34 36 36 38 38 38 39 39 44
24
0 2 3 5 7 9 9 10 11 12 13 14 14 14 14 15 1...

output:

0
0
0
0
0
0
237895680
0
0
0
0
0
719792751
0
76653157
36
281095197
62819328
2
0
868501340
0
0
2
0
0
0
0
143768790
0
0
718257845
160
0
93312
0
0
0
278243162
0
2
0
0
0
0
2
0
2
710546436
0
0
0
0
4
0
0
0
742806204
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
10976
0
0
31496192
0
0
2
64
0
0
890138681
0
0
464001971...

result:

wrong answer 7th lines differ - expected: '24576', found: '237895680'