Submission #963218

#TimeUsernameProblemLanguageResultExecution timeMemory
963218fzyzzz_zFish (IOI08_fish)C++17
0 / 100
210 ms15404 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 500005; int m; struct seg { vector<int> t; seg(vector<int> f) { t = vector<int>(2 * f.size()); for (int i = 0; i < f.size(); ++i) t[i + f.size()] = f[i] + 1; for (int i = f.size() - 1; i >= 1; --i) t[i] = ((ll)t[2 * i] * t[2 * i + 1]) % m; } void upd(int p, int v) { p += t.size() / 2; t[p] += v; t[p] = max(t[p], 1); for (; p > 1; p /= 2) { t[p / 2] = ((ll)t[p] * t[p ^ 1]) % m; } } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k >> m; vector<int> f(k, 0); vector<pair<int, int>> a(n); for (auto & [x, y]: a) { cin >> x >> y; f[--y]++; } seg s(f); sort(a.begin(), a.end(), greater<pair<int, int>>()); int ans = 0; f = vector<int>(k, 0); for (int i = 0, j = 0; i < n; ++i) { if (f[a[i].second]) continue; f[a[i].second] = 1; while (a[j].first * 2 > a[i].first && j < n) { s.upd(a[j].second, -1); j++; } if (i != 0) s.upd(a[j].second, -n); ans += s.t[1]; if (i > 0) s.upd(a[j].second, -n); ans %= m; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

fish.cpp: In constructor 'seg::seg(std::vector<int>)':
fish.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int i = 0; i < f.size(); ++i) t[i + f.size()] = f[i] + 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...
#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...