Submission #826806

#TimeUsernameProblemLanguageResultExecution timeMemory
826806t6twotwoFestivals in JOI Kingdom 2 (JOI23_festival2)C++17
5 / 100
9102 ms324 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, P; cin >> N >> P; vector<int> a(2 * N); iota(a.begin(), a.end(), 1); int ans = 0; do { bool ok = 1; for (int i = 0; i < N; i++) { if (a[i] > a[N + i]) { ok = 0; } if (i && a[i - 1] > a[i]) { ok = 0; } } if (!ok) { continue; } int s = 0, f = 0; for (int i = 0; i < N; i++) { if (a[i] > f) { s++; f = max(f, a[i + N]); } } int t = 0; f = 0; vector<int> ord(N); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int i, int j) { return a[N + i] < a[N + j]; }); for (int i = 0; i < N; i++) { if (i == 0 || a[ord[i]] > f) { t++; f = a[N + ord[i]]; } } if (s < t) { ans++; } } while (next_permutation(a.begin(), a.end())); cout << ans << "\n"; return 6/22; }
#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...