답안 #528100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528100 2022-02-19T09:15:36 Z kaxzert Amusement Park (CEOI19_amusementpark) C++17
42 / 100
3000 ms 170776 KB
/**
      ⚡⚡  ⚡⚡      ⚡⚡⚡     ⚡⚡  ⚡⚡  ⚡⚡⚡⚡⚡⚡   ⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡⚡
      ⚡⚡ ⚡⚡      ⚡⚡⚡⚡     ⚡⚡⚡⚡      ⚡⚡      ⚡⚡       ⚡⚡    ⚡⚡  ⚡⚡⚡⚡⚡⚡
      ⚡⚡⚡⚡      ⚡⚡  ⚡⚡      ⚡⚡      ⚡⚡       ⚡⚡⚡⚡⚡   ⚡⚡⚡⚡⚡⚡     ⚡⚡
      ⚡⚡ ⚡⚡    ⚡⚡⚡⚡⚡⚡     ⚡⚡     ⚡⚡         ⚡⚡       ⚡⚡  ⚡⚡       ⚡⚡
      ⚡⚡  ⚡⚡  ⚡⚡     ⚡⚡  ⚡⚡ ⚡⚡  ⚡⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡    ⚡⚡   ⚡⚡     ⚡⚡
**/

#include<bits/stdc++.h>

using namespace std;

#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl;
#define ll long long
#define db double
#define ldb long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define vt vector
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(i, a) for(auto &i : a)
#define sz(a) (int)a.size()
#define pi(a, b) pair<a, b>
#define fast ios::sync_with_stdio(false); cin.tie(0)

void setIO(string s) {
    if (sz(s) != 0) {
        freopen((s+".inp").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

void setIOusaco(string s) {
    if (sz(s) != 0) {
        freopen((s+".in").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

template<typename T, typename V>
bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;}
template<typename T, typename V>
bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;}

const int maxN = 20;
const int oo = 998244353;

void print(int x) {cout << x;}
void print(long long x) {cout << x;}
void print(unsigned x) {cout << x;}
void print(unsigned long long x) {cout << x;}
void print(double x) {cout << fixed << x;}
void print(long double x) {cout << fixed << x;}
void print(char x) {cout << "'" << x << "'";}
void print(string x) {cout << '"' << x << '"';}
void print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void print(const pair<T, V> &x) {cout << '{'; print(x.ff); cout << ", "; print(x.ss); cout << '}';}
template<typename T>
void print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? ", " : ""), print(i); cout << "}";}
void _print() {cout << "]" << endl;}
template <typename T, typename... V>
void _print(T t, V... v) {print(t); if (sizeof...(v)) cout << ", "; _print(v...);}

#ifdef TAP
#define bug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define bug(x...) 
#endif

int main() {
    #ifndef TAP 
    setIO("");
    //setIOusaco("CEOI19_amusementpark");
    #endif

    fast;
    int n, m;
    cin >> n >> m;
    vt<pi(int, int)> edges;
    fto(i, 1, m) {
        int u, v;
        cin >> u >> v;
        edges.pb({u, v});
    }

    vt<int> a(n);
    iota(all(a), 0);

    set<ll> exist;
    int ans = 0;
    do {
        ll sth = 0;
        fto(i, 0, m-1) {
            if (a[edges[i].ff-1] < a[edges[i].ss-1]) sth |= (1LL<<i);
        }
        if (exist.find(sth) == exist.end()) {
            if ((ans += __builtin_popcountll(sth)) > oo) ans -= oo;
            exist.insert(sth);
        }
    } while(next_permutation(all(a)));

    cout << ans << '\n';

    return 0;
}

Compilation message

amusementpark.cpp: In function 'void setIO(std::string)':
amusementpark.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen((s+".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp: In function 'void setIOusaco(std::string)':
amusementpark.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 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 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 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 312 KB Output is correct
11 Correct 0 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 0 ms 308 KB Output is correct
15 Correct 0 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 0 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 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 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 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 312 KB Output is correct
11 Correct 0 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 0 ms 308 KB Output is correct
15 Correct 0 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 0 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 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 460 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 316 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 6 ms 484 KB Output is correct
36 Correct 8 ms 716 KB Output is correct
37 Correct 13 ms 1364 KB Output is correct
38 Correct 17 ms 2176 KB Output is correct
39 Correct 6 ms 204 KB Output is correct
40 Correct 14 ms 320 KB Output is correct
41 Correct 25 ms 352 KB Output is correct
42 Correct 32 ms 536 KB Output is correct
43 Correct 58 ms 1580 KB Output is correct
44 Correct 76 ms 2752 KB Output is correct
45 Correct 99 ms 5792 KB Output is correct
46 Correct 141 ms 10928 KB Output is correct
47 Correct 185 ms 17228 KB Output is correct
48 Correct 10 ms 328 KB Output is correct
49 Correct 18 ms 500 KB Output is correct
50 Correct 26 ms 436 KB Output is correct
51 Correct 32 ms 408 KB Output is correct
52 Correct 62 ms 204 KB Output is correct
53 Correct 155 ms 572 KB Output is correct
54 Correct 272 ms 580 KB Output is correct
55 Correct 505 ms 1812 KB Output is correct
56 Correct 570 ms 8772 KB Output is correct
57 Correct 874 ms 22808 KB Output is correct
58 Correct 1265 ms 48584 KB Output is correct
59 Correct 1618 ms 94656 KB Output is correct
60 Correct 2345 ms 170776 KB Output is correct
61 Correct 104 ms 204 KB Output is correct
62 Correct 191 ms 828 KB Output is correct
63 Correct 247 ms 968 KB Output is correct
64 Correct 330 ms 976 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 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 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 312 KB Output is correct
11 Correct 0 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 0 ms 308 KB Output is correct
15 Correct 0 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 0 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 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 460 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 316 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 6 ms 484 KB Output is correct
36 Correct 8 ms 716 KB Output is correct
37 Correct 13 ms 1364 KB Output is correct
38 Correct 17 ms 2176 KB Output is correct
39 Correct 6 ms 204 KB Output is correct
40 Correct 14 ms 320 KB Output is correct
41 Correct 25 ms 352 KB Output is correct
42 Correct 32 ms 536 KB Output is correct
43 Correct 58 ms 1580 KB Output is correct
44 Correct 76 ms 2752 KB Output is correct
45 Correct 99 ms 5792 KB Output is correct
46 Correct 141 ms 10928 KB Output is correct
47 Correct 185 ms 17228 KB Output is correct
48 Correct 10 ms 328 KB Output is correct
49 Correct 18 ms 500 KB Output is correct
50 Correct 26 ms 436 KB Output is correct
51 Correct 32 ms 408 KB Output is correct
52 Correct 62 ms 204 KB Output is correct
53 Correct 155 ms 572 KB Output is correct
54 Correct 272 ms 580 KB Output is correct
55 Correct 505 ms 1812 KB Output is correct
56 Correct 570 ms 8772 KB Output is correct
57 Correct 874 ms 22808 KB Output is correct
58 Correct 1265 ms 48584 KB Output is correct
59 Correct 1618 ms 94656 KB Output is correct
60 Correct 2345 ms 170776 KB Output is correct
61 Correct 104 ms 204 KB Output is correct
62 Correct 191 ms 828 KB Output is correct
63 Correct 247 ms 968 KB Output is correct
64 Correct 330 ms 976 KB Output is correct
65 Execution timed out 3074 ms 5580 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 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 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 312 KB Output is correct
11 Correct 0 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 0 ms 308 KB Output is correct
15 Correct 0 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 0 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 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 460 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 316 KB Output is correct
34 Correct 4 ms 320 KB Output is correct
35 Correct 6 ms 484 KB Output is correct
36 Correct 8 ms 716 KB Output is correct
37 Correct 13 ms 1364 KB Output is correct
38 Correct 17 ms 2176 KB Output is correct
39 Correct 6 ms 204 KB Output is correct
40 Correct 14 ms 320 KB Output is correct
41 Correct 25 ms 352 KB Output is correct
42 Correct 32 ms 536 KB Output is correct
43 Correct 58 ms 1580 KB Output is correct
44 Correct 76 ms 2752 KB Output is correct
45 Correct 99 ms 5792 KB Output is correct
46 Correct 141 ms 10928 KB Output is correct
47 Correct 185 ms 17228 KB Output is correct
48 Correct 10 ms 328 KB Output is correct
49 Correct 18 ms 500 KB Output is correct
50 Correct 26 ms 436 KB Output is correct
51 Correct 32 ms 408 KB Output is correct
52 Correct 62 ms 204 KB Output is correct
53 Correct 155 ms 572 KB Output is correct
54 Correct 272 ms 580 KB Output is correct
55 Correct 505 ms 1812 KB Output is correct
56 Correct 570 ms 8772 KB Output is correct
57 Correct 874 ms 22808 KB Output is correct
58 Correct 1265 ms 48584 KB Output is correct
59 Correct 1618 ms 94656 KB Output is correct
60 Correct 2345 ms 170776 KB Output is correct
61 Correct 104 ms 204 KB Output is correct
62 Correct 191 ms 828 KB Output is correct
63 Correct 247 ms 968 KB Output is correct
64 Correct 330 ms 976 KB Output is correct
65 Execution timed out 3074 ms 5580 KB Time limit exceeded
66 Halted 0 ms 0 KB -