답안 #861257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861257 2023-10-15T18:00:51 Z Irate Cryptography (NOI20_crypto) C++14
25 / 100
25 ms 5604 KB
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int mxN = 3e5 + 5;
int fact[mxN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i = 0;i < n;++i){
        cin >> v[i];
    }
    fact[0] = fact[1] = 1;
    for(int i = 2;i <= n;++i){
        fact[i] = (long long)fact[i - 1] * i % MOD;
    }
    if(n >= 1 && n <= 8){
        vector<int>cpy = v;
        sort(cpy.begin(), cpy.end());
        int cnt = 1;
        do{
            bool check = 1;
            for(int i = 0;i < n;++i){
                if(cpy[i] != v[i]){
                    check = 0;
                    break;
                }
            }
            if(check){
                cout << cnt;
                return 0;
            }
            cnt++;
        }while(next_permutation(cpy.begin(), cpy.end()));
    }
    if(v[1] == 1){
        cout << (((long long)v[0] - 1) * fact[n - 1] % MOD + 1) % MOD;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 25 ms 5604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 20 ms 4704 KB Output is correct
3 Correct 21 ms 4700 KB Output is correct
4 Correct 20 ms 4700 KB Output is correct
5 Correct 21 ms 4688 KB Output is correct
6 Correct 21 ms 4572 KB Output is correct
7 Correct 23 ms 4572 KB Output is correct
8 Correct 20 ms 4688 KB Output is correct
9 Correct 24 ms 4828 KB Output is correct
10 Correct 20 ms 4576 KB Output is correct
11 Correct 20 ms 4692 KB Output is correct
12 Correct 21 ms 4708 KB Output is correct
13 Correct 20 ms 4688 KB Output is correct
14 Correct 20 ms 4692 KB Output is correct
15 Correct 20 ms 4692 KB Output is correct
16 Correct 20 ms 4700 KB Output is correct
17 Correct 20 ms 4700 KB Output is correct
18 Correct 20 ms 4700 KB Output is correct
19 Correct 20 ms 4692 KB Output is correct
20 Correct 20 ms 4688 KB Output is correct
21 Correct 20 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Incorrect 1 ms 348 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 20 ms 4704 KB Output is correct
3 Correct 21 ms 4700 KB Output is correct
4 Correct 20 ms 4700 KB Output is correct
5 Correct 21 ms 4688 KB Output is correct
6 Correct 21 ms 4572 KB Output is correct
7 Correct 23 ms 4572 KB Output is correct
8 Correct 20 ms 4688 KB Output is correct
9 Correct 24 ms 4828 KB Output is correct
10 Correct 20 ms 4576 KB Output is correct
11 Correct 20 ms 4692 KB Output is correct
12 Correct 21 ms 4708 KB Output is correct
13 Correct 20 ms 4688 KB Output is correct
14 Correct 20 ms 4692 KB Output is correct
15 Correct 20 ms 4692 KB Output is correct
16 Correct 20 ms 4700 KB Output is correct
17 Correct 20 ms 4700 KB Output is correct
18 Correct 20 ms 4700 KB Output is correct
19 Correct 20 ms 4692 KB Output is correct
20 Correct 20 ms 4688 KB Output is correct
21 Correct 20 ms 4700 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Incorrect 1 ms 348 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Incorrect 25 ms 5604 KB Output isn't correct
27 Halted 0 ms 0 KB -