Submission #1110511

# Submission time Handle Problem Language Result Execution time Memory
1110511 2024-11-09T15:30:40 Z cpptowin Amusement Park (CEOI19_amusementpark) C++17
42 / 100
3000 ms 170700 KB
#include <bits/stdc++.h>
#define fo(i, d, c) for (int i = d; i <= c; i++)
#define fod(i, c, d) for (int i = c; i >= d; i--)
#define maxn 1000010
#define N 1010
#define fi first
#define se second
#define pb emplace_back
#define en cout << "\n";
#define int long long
#define inf (int)1e18
#define bitcount(x) __builtin_popcountll(x)
#define pii pair<int, int>
#define vii vector<pii>
#define lb(x) x & -x
#define bit(i, j) ((i >> j) & 1)
#define offbit(i, j) (i ^ (1LL << j))
#define onbit(i, j) (i | (1LL << j))
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define ss(x) (int)x.size()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template <typename T1, typename T2>
bool minimize(T1 &a, T2 b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool maximize(T1 &a, T2 b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
const int nsqrt = 450;
const int mod = 1e9 + 7;
void add(int &x, int k)
{
    x += k;
    x %= mod;
    if (x < 0)
        x += mod;
}
void del(int &x, int k)
{
    x -= k;
    x %= mod;
    if (x < 0)
        x += mod;
}
int n, m;
pii a[N];
int id[20],pos[20];
main()
{
#define name "TASK"
    if (fopen(name ".inp", "r"))
    {
        freopen(name ".inp", "r", stdin);
        freopen(name ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    fo(i, 0, m - 1) cin >> a[i].fi >> a[i].se;
    fo(i, 1, n) id[i] = i;
    set<int> st;
    do
    {
        fo(i,1,n) pos[id[i]] = i;
        int mask = 0;
        fo(i,0,m - 1) 
        {
            auto [u,v] = a[i];
            if(pos[u] > pos[v]) mask = onbit(mask,i);
        }
        st.insert(mask);
    } while (next_permutation(id + 1, id + n + 1));
    int ans = 0;
    for(int it : st) ans += bitcount(it);
    cout << ans;
}

Compilation message

amusementpark.cpp:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   63 | main()
      | ^~~~
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(name ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 6 ms 848 KB Output is correct
37 Correct 8 ms 1528 KB Output is correct
38 Correct 10 ms 2128 KB Output is correct
39 Correct 6 ms 460 KB Output is correct
40 Correct 9 ms 336 KB Output is correct
41 Correct 14 ms 504 KB Output is correct
42 Correct 21 ms 592 KB Output is correct
43 Correct 33 ms 1616 KB Output is correct
44 Correct 40 ms 2732 KB Output is correct
45 Correct 62 ms 5968 KB Output is correct
46 Correct 94 ms 10976 KB Output is correct
47 Correct 109 ms 17448 KB Output is correct
48 Correct 9 ms 336 KB Output is correct
49 Correct 17 ms 464 KB Output is correct
50 Correct 22 ms 592 KB Output is correct
51 Correct 17 ms 592 KB Output is correct
52 Correct 60 ms 336 KB Output is correct
53 Correct 105 ms 464 KB Output is correct
54 Correct 157 ms 656 KB Output is correct
55 Correct 230 ms 1764 KB Output is correct
56 Correct 378 ms 8764 KB Output is correct
57 Correct 487 ms 22600 KB Output is correct
58 Correct 696 ms 48628 KB Output is correct
59 Correct 945 ms 94792 KB Output is correct
60 Correct 1325 ms 170700 KB Output is correct
61 Correct 87 ms 464 KB Output is correct
62 Correct 205 ms 964 KB Output is correct
63 Correct 182 ms 928 KB Output is correct
64 Correct 174 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 6 ms 848 KB Output is correct
37 Correct 8 ms 1528 KB Output is correct
38 Correct 10 ms 2128 KB Output is correct
39 Correct 6 ms 460 KB Output is correct
40 Correct 9 ms 336 KB Output is correct
41 Correct 14 ms 504 KB Output is correct
42 Correct 21 ms 592 KB Output is correct
43 Correct 33 ms 1616 KB Output is correct
44 Correct 40 ms 2732 KB Output is correct
45 Correct 62 ms 5968 KB Output is correct
46 Correct 94 ms 10976 KB Output is correct
47 Correct 109 ms 17448 KB Output is correct
48 Correct 9 ms 336 KB Output is correct
49 Correct 17 ms 464 KB Output is correct
50 Correct 22 ms 592 KB Output is correct
51 Correct 17 ms 592 KB Output is correct
52 Correct 60 ms 336 KB Output is correct
53 Correct 105 ms 464 KB Output is correct
54 Correct 157 ms 656 KB Output is correct
55 Correct 230 ms 1764 KB Output is correct
56 Correct 378 ms 8764 KB Output is correct
57 Correct 487 ms 22600 KB Output is correct
58 Correct 696 ms 48628 KB Output is correct
59 Correct 945 ms 94792 KB Output is correct
60 Correct 1325 ms 170700 KB Output is correct
61 Correct 87 ms 464 KB Output is correct
62 Correct 205 ms 964 KB Output is correct
63 Correct 182 ms 928 KB Output is correct
64 Correct 174 ms 840 KB Output is correct
65 Execution timed out 3063 ms 9164 KB Time limit exceeded
66 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 6 ms 848 KB Output is correct
37 Correct 8 ms 1528 KB Output is correct
38 Correct 10 ms 2128 KB Output is correct
39 Correct 6 ms 460 KB Output is correct
40 Correct 9 ms 336 KB Output is correct
41 Correct 14 ms 504 KB Output is correct
42 Correct 21 ms 592 KB Output is correct
43 Correct 33 ms 1616 KB Output is correct
44 Correct 40 ms 2732 KB Output is correct
45 Correct 62 ms 5968 KB Output is correct
46 Correct 94 ms 10976 KB Output is correct
47 Correct 109 ms 17448 KB Output is correct
48 Correct 9 ms 336 KB Output is correct
49 Correct 17 ms 464 KB Output is correct
50 Correct 22 ms 592 KB Output is correct
51 Correct 17 ms 592 KB Output is correct
52 Correct 60 ms 336 KB Output is correct
53 Correct 105 ms 464 KB Output is correct
54 Correct 157 ms 656 KB Output is correct
55 Correct 230 ms 1764 KB Output is correct
56 Correct 378 ms 8764 KB Output is correct
57 Correct 487 ms 22600 KB Output is correct
58 Correct 696 ms 48628 KB Output is correct
59 Correct 945 ms 94792 KB Output is correct
60 Correct 1325 ms 170700 KB Output is correct
61 Correct 87 ms 464 KB Output is correct
62 Correct 205 ms 964 KB Output is correct
63 Correct 182 ms 928 KB Output is correct
64 Correct 174 ms 840 KB Output is correct
65 Execution timed out 3063 ms 9164 KB Time limit exceeded
66 Halted 0 ms 0 KB -