Submission #501248

#TimeUsernameProblemLanguageResultExecution timeMemory
501248600MihneaFish (IOI08_fish)C++17
12 / 100
3093 ms65540 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; signed main() { ios::sync_with_stdio(0); cin.tie(0); // freopen ("input", "r", stdin); int n, k, mod; cin >> n >> k >> mod; vector<pair<int, int>> a(n); vector<bool> deja(k, 0), skip(n, 0); for (auto &it : a) { cin >> it.first >> it.second; it.second--; } sort(a.begin(), a.end()); for (int i = n - 1; i >= 0; i--) { if (!deja[a[i].second]) { deja[a[i].second] = 1; } else { skip[i] = 1; } } vector<vector<int>> frqs; int limit = 0; for (int i = 0; i < n; i++) { if (skip[i]) { continue; } while (limit < n && 2 * a[limit].first <= a[i].first) { limit++; } vector<int> frq(k, 0); for (int j = 0; j < limit; j++) { frq[a[j].second]++; } frq[a[i].second]++; frqs.push_back(frq); } n = (int) frqs.size(); int print = 0; for (int mask = 1; mask < (1 << n); mask++) { vector<int> guys; for (int i = 0; i < n; i++) { if (mask & (1 << i)) { guys.push_back(i); } } vector<int> base = frqs[guys[0]]; for (int j = 1; j < (int) guys.size(); j++) { for (int i = 0; i < k; i++) { base[i] = min(base[i], frqs[guys[j]][i]); } } int prod = 1; for (int i = 0; i < k; i++) { prod = (ll) prod * (base[i] + 1) % mod; } if ((int) guys.size() % 2 == 1) { print = (print + prod) % mod; } else { print = (print - prod + mod) % mod; } } print = (print + mod - 1) % mod; cout << print << "\n"; return 0; }
#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...
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...