Submission #941621

# Submission time Handle Problem Language Result Execution time Memory
941621 2024-03-09T08:02:39 Z TAhmed33 Festivals in JOI Kingdom 2 (JOI23_festival2) C++
10 / 100
9000 ms 432 KB
#include <bits/stdc++.h>
using namespace std;
bool vis[17];
int a[9], b[9];
int n;
int cnt = 0;
void recurse (int pos) {
    if (pos == n + 1) {
        vector <pair <int, int>> dd;
        for (int i = 1; i <= n; i++) {
            dd.push_back({a[i], b[i]});
        }
        int c1 = 0, c2 = 0;
        sort(dd.begin(), dd.end());
        int prev = 0;
        for (auto i : dd) {
            if (i.first > prev) {
                c1++; prev = i.second;
            }
        }
        sort(dd.begin(), dd.end(), [&] (pair <int, int> &x, pair <int, int> &y) {
            return x.second < y.second;
        });
        prev = 0;
        for (auto i : dd) {
            if (i.first > prev) {
                c2++; prev = i.second;
            }
        }
        if (c1 < c2) cnt++;
        return;
    }
    int u; for (int i = 1; i <= 2 * n; i++) {
        if (!vis[i]) {
            u = i;
            break;
        }
    }
    a[pos] = u; vis[u] = 1;
    for (int i = 1; i <= 2 * n; i++) {
        if (!vis[i]) {
            vis[i] = 1;
            b[pos] = i;
            recurse(pos + 1);
            vis[i] = 0;
        }
    }
    vis[u] = 0;
}
int main () {
    cin >> n;
    recurse(1);
    cout << cnt << '\n';
}

Compilation message

festival2.cpp: In function 'void recurse(int)':
festival2.cpp:39:12: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |     a[pos] = u; vis[u] = 1;
      |     ~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 436 ms 424 KB Output is correct
9 Correct 445 ms 412 KB Output is correct
10 Correct 438 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 27 ms 412 KB Output is correct
13 Correct 27 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 436 ms 424 KB Output is correct
9 Correct 445 ms 412 KB Output is correct
10 Correct 438 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 27 ms 412 KB Output is correct
13 Correct 27 ms 412 KB Output is correct
14 Execution timed out 9016 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 436 ms 424 KB Output is correct
9 Correct 445 ms 412 KB Output is correct
10 Correct 438 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 27 ms 412 KB Output is correct
13 Correct 27 ms 412 KB Output is correct
14 Execution timed out 9016 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 436 ms 424 KB Output is correct
9 Correct 445 ms 412 KB Output is correct
10 Correct 438 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 27 ms 412 KB Output is correct
13 Correct 27 ms 412 KB Output is correct
14 Execution timed out 9016 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 436 ms 424 KB Output is correct
9 Correct 445 ms 412 KB Output is correct
10 Correct 438 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 27 ms 412 KB Output is correct
13 Correct 27 ms 412 KB Output is correct
14 Execution timed out 9016 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -