답안 #479924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
479924 2021-10-13T23:50:57 Z Ozy Amusement Park (CEOI19_amusementpark) C++17
42 / 100
3000 ms 161996 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 18
#define mod 998244353

lli n,m,total;
lli pot[47],orden[MAX+2];
pair<lli,lli> slides[47];
unordered_map<lli, lli> mapa;

void checa() {

    lli num = 0;
    lli rparcial = 0;

    rep(i,1,m) {
        if (orden[slides[i].first] > orden[slides[i].second]) {
            num += pot[i];
            rparcial++;
        }
    }

    if (mapa.find(num) == mapa.end()) {
        mapa[num] = 1;
        total += rparcial;
        if (total >= mod) total -= mod;
    }

}

void genera(lli k) {
    rep(i,1,n) {
        if (orden[i] > 0) continue;

        orden[i] = k;
        if (k == n) checa();
        else genera(k+1);
        orden[i] = 0;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    rep(i,1,m) cin >> slides[i].first >> slides[i].second;

    pot[1] = 1;
    rep(i,2,m) pot[i] = pot[i-1]*2;

    genera(1);

    cout << total;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 456 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 5 ms 460 KB Output is correct
36 Correct 7 ms 828 KB Output is correct
37 Correct 10 ms 1356 KB Output is correct
38 Correct 12 ms 1832 KB Output is correct
39 Correct 20 ms 292 KB Output is correct
40 Correct 24 ms 204 KB Output is correct
41 Correct 28 ms 332 KB Output is correct
42 Correct 35 ms 460 KB Output is correct
43 Correct 44 ms 1488 KB Output is correct
44 Correct 55 ms 2580 KB Output is correct
45 Correct 80 ms 5336 KB Output is correct
46 Correct 108 ms 10032 KB Output is correct
47 Correct 178 ms 19560 KB Output is correct
48 Correct 25 ms 320 KB Output is correct
49 Correct 33 ms 460 KB Output is correct
50 Correct 34 ms 448 KB Output is correct
51 Correct 33 ms 404 KB Output is correct
52 Correct 209 ms 204 KB Output is correct
53 Correct 252 ms 324 KB Output is correct
54 Correct 321 ms 692 KB Output is correct
55 Correct 379 ms 1568 KB Output is correct
56 Correct 474 ms 9768 KB Output is correct
57 Correct 648 ms 20780 KB Output is correct
58 Correct 1002 ms 43964 KB Output is correct
59 Correct 1550 ms 86180 KB Output is correct
60 Correct 2515 ms 161996 KB Output is correct
61 Correct 243 ms 324 KB Output is correct
62 Correct 339 ms 964 KB Output is correct
63 Correct 325 ms 836 KB Output is correct
64 Correct 326 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 456 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 5 ms 460 KB Output is correct
36 Correct 7 ms 828 KB Output is correct
37 Correct 10 ms 1356 KB Output is correct
38 Correct 12 ms 1832 KB Output is correct
39 Correct 20 ms 292 KB Output is correct
40 Correct 24 ms 204 KB Output is correct
41 Correct 28 ms 332 KB Output is correct
42 Correct 35 ms 460 KB Output is correct
43 Correct 44 ms 1488 KB Output is correct
44 Correct 55 ms 2580 KB Output is correct
45 Correct 80 ms 5336 KB Output is correct
46 Correct 108 ms 10032 KB Output is correct
47 Correct 178 ms 19560 KB Output is correct
48 Correct 25 ms 320 KB Output is correct
49 Correct 33 ms 460 KB Output is correct
50 Correct 34 ms 448 KB Output is correct
51 Correct 33 ms 404 KB Output is correct
52 Correct 209 ms 204 KB Output is correct
53 Correct 252 ms 324 KB Output is correct
54 Correct 321 ms 692 KB Output is correct
55 Correct 379 ms 1568 KB Output is correct
56 Correct 474 ms 9768 KB Output is correct
57 Correct 648 ms 20780 KB Output is correct
58 Correct 1002 ms 43964 KB Output is correct
59 Correct 1550 ms 86180 KB Output is correct
60 Correct 2515 ms 161996 KB Output is correct
61 Correct 243 ms 324 KB Output is correct
62 Correct 339 ms 964 KB Output is correct
63 Correct 325 ms 836 KB Output is correct
64 Correct 326 ms 848 KB Output is correct
65 Execution timed out 3053 ms 6508 KB Time limit exceeded
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 456 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 3 ms 204 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 5 ms 460 KB Output is correct
36 Correct 7 ms 828 KB Output is correct
37 Correct 10 ms 1356 KB Output is correct
38 Correct 12 ms 1832 KB Output is correct
39 Correct 20 ms 292 KB Output is correct
40 Correct 24 ms 204 KB Output is correct
41 Correct 28 ms 332 KB Output is correct
42 Correct 35 ms 460 KB Output is correct
43 Correct 44 ms 1488 KB Output is correct
44 Correct 55 ms 2580 KB Output is correct
45 Correct 80 ms 5336 KB Output is correct
46 Correct 108 ms 10032 KB Output is correct
47 Correct 178 ms 19560 KB Output is correct
48 Correct 25 ms 320 KB Output is correct
49 Correct 33 ms 460 KB Output is correct
50 Correct 34 ms 448 KB Output is correct
51 Correct 33 ms 404 KB Output is correct
52 Correct 209 ms 204 KB Output is correct
53 Correct 252 ms 324 KB Output is correct
54 Correct 321 ms 692 KB Output is correct
55 Correct 379 ms 1568 KB Output is correct
56 Correct 474 ms 9768 KB Output is correct
57 Correct 648 ms 20780 KB Output is correct
58 Correct 1002 ms 43964 KB Output is correct
59 Correct 1550 ms 86180 KB Output is correct
60 Correct 2515 ms 161996 KB Output is correct
61 Correct 243 ms 324 KB Output is correct
62 Correct 339 ms 964 KB Output is correct
63 Correct 325 ms 836 KB Output is correct
64 Correct 326 ms 848 KB Output is correct
65 Execution timed out 3053 ms 6508 KB Time limit exceeded
66 Halted 0 ms 0 KB -