Submission #1111015

# Submission time Handle Problem Language Result Execution time Memory
1111015 2024-11-11T10:01:43 Z crafticat Amusement Park (CEOI19_amusementpark) C++17
7 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

template<typename T>
using V = vector<T>;
using vi = V<int>;
using vb = V<bool>;
using pi = pair<int,int>;

#define F0R(i,n) for (int i = 0; i < n;i++)
#define FOR(i, j, n) for(int i = j; i < n;i++)
#define ckmin(x,y) x = min(x,y)
#define f first
#define s second
using ll = long long;
constexpr int MOD = 998244353;

V<int> vis;
V<V<int>> g;

bool dfs(int x) {
    if (vis[x] == 1) return false;
    vis[x] = 1;
    for (auto y : g[x]) {
        if (vis[y] == 2) continue;
        if (!dfs(y)) return false;
    }

    vis[x] = 2;
    return true;
}

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

    int n, m; cin >> n >> m;
    V<pi> edges(m);
    set<pi> exists;

    F0R(i, m) {
        int x, y; cin >> x >> y;
        x--;
        y--;
        edges[i] = {x,y};
        exists.insert({x,y});
        exists.insert({y,x});
    }

    ll ans = 0;
    vi perm(n); // Height of I
    F0R(i, n)
        perm[i] = i;

    do {
        int cost = 0;
        for (auto [a,b] : edges) {
            if (perm[a] > perm[b]) cost++;
        }
        bool pos = true;
        vi inv(n);
        F0R(i, n) {
            inv[perm[i]] = i;
        }

        F0R(i, n - 1) {
            int a = inv[i];
            int b = inv[i + 1];
            if (a < b && !exists.count({a,b})) pos = false;
        }
        if (pos) ans += cost;
        else {
            int stop = 25;
        }
        ans %= MOD;
    } while (std::next_permutation(perm.begin(), perm.end()));

    cout << ans;

    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:73:17: warning: unused variable 'stop' [-Wunused-variable]
   73 |             int stop = 25;
      |                 ^~~~
# 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 348 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 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 348 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 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 348 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 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 348 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 Halted 0 ms 0 KB -