Submission #519722

# Submission time Handle Problem Language Result Execution time Memory
519722 2022-01-27T07:06:21 Z Monarchuwu Amusement Park (CEOI19_amusementpark) C++17
19 / 100
72 ms 13120 KB
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
#define ff first
#define ss second

const int N = 2e5 + 8, mod = 998244353;
int n, m;
pii edge[N];

vector<int> g[N];
void loadGraph(int mask) {
    for (int i = 1; i <= n; ++i) g[i].clear();
    for (int i = 0; i < m; ++i)
        if (mask >> i & 1)
            g[edge[i].ss].push_back(edge[i].ff);
        else g[edge[i].ff].push_back(edge[i].ss);
}

int vis[N];
bool dfs(int u) {
    vis[u] = 1;
    for (int v : g[u])
        if (vis[v] == 1 || (!vis[v] && dfs(v))) return true;
    vis[u] = 2;
    return false;
}
bool check() {
    fill(vis + 1, vis + n + 1, 0);
    for (int i = 1; i <= n; ++i)
        if (!vis[i] && dfs(i)) return false;
    return true;
}

int lg[N];
int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
        cin >> edge[i].ff >> edge[i].ss;

    ll cnt(0);
    for (int mask = 1; mask < (1 << m); ++mask) {
        lg[mask] = lg[mask >> 1] + (mask & 1);
        loadGraph(mask);
        if (check())
            cnt += lg[mask];
    }
    cout << cnt % mod << '\n';
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 2 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 2 ms 4940 KB Output is correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 2 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 2 ms 4940 KB Output is correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 2 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 2 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 2 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 4940 KB Output is correct
20 Correct 3 ms 5020 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 8 ms 5068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 2 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 2 ms 4940 KB Output is correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 2 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 2 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 2 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 4940 KB Output is correct
20 Correct 3 ms 5020 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 8 ms 5068 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 2 ms 5016 KB Output is correct
27 Correct 3 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 7 ms 5152 KB Output is correct
30 Correct 40 ms 5912 KB Output is correct
31 Runtime error 72 ms 13120 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 2 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 2 ms 4940 KB Output is correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 2 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 2 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 2 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 4940 KB Output is correct
20 Correct 3 ms 5020 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 8 ms 5068 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 2 ms 5016 KB Output is correct
27 Correct 3 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 7 ms 5152 KB Output is correct
30 Correct 40 ms 5912 KB Output is correct
31 Runtime error 72 ms 13120 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 2 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 2 ms 4940 KB Output is correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 2 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 2 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 2 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 4940 KB Output is correct
20 Correct 3 ms 5020 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 8 ms 5068 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 2 ms 5016 KB Output is correct
27 Correct 3 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 7 ms 5152 KB Output is correct
30 Correct 40 ms 5912 KB Output is correct
31 Runtime error 72 ms 13120 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -