Submission #941621

#TimeUsernameProblemLanguageResultExecution timeMemory
941621TAhmed33Festivals in JOI Kingdom 2 (JOI23_festival2)C++98
10 / 100
9016 ms432 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...