# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734017 | 2023-05-01T13:41:32 Z | lorenzoferrari | Fish (IOI08_fish) | C++17 | 3000 ms | 44372 KB |
#include "bits/stdc++.h" using namespace std; #define int long long static constexpr int N = 5e5+5; struct fish { int l; int g; bool operator<(const fish& oth) { return l < oth.l; } }; static int f[N]; // frq of each colour static int ff[N]; // frq of each frq set<int> s; // {j | ff[j] != 0} vector<int> pw[N]; static void inc(int c, int m) { if (ff[f[c]] == 1) { s.erase(f[c]); } --ff[f[c]]; ++f[c]; ++ff[f[c]]; if (ff[f[c]] == 1) { s.insert(f[c]); } pw[f[c]+1].emplace_back(pw[f[c]+1].back() * ((f[c]+1) % m) % m); } static int calc(int m) { int ans = 1; for (int j : s) { ans = ans * pw[j+1][ff[j]] % m; } return ans; } signed main() { for (int i = 0; i < N; ++i) { pw[i].emplace_back(1); } int n; cin >> n; int k; cin >> k; int m; cin >> m; vector<fish> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].l >> a[i].g; --a[i].g; } sort(begin(a), end(a)); vector<int> last(k); for (int i = 0; i < n; ++i) { last[a[i].g] = i; } int ans = 0; vector<int> d(n); vector<int> rs; for (int r = 0, l = 0; r < n; ++r) { if (last[a[r].g] != r) continue; while (2*a[l].l <= a[r].l) { inc(a[l].g, m); ++l; continue; if (last[a[l].g] < r) { inc(a[l].g, m); } else { ++d[last[a[l].g]]; } ++l; } while (d[r]--) { inc(a[r].g, m); } rs.push_back(r); int cur = 1; for (int i : rs) { cur = (cur * (f[a[i].g]+1)) % m; } ans += cur; ans %= m; // ans = (ans + calc(m)) % m; } cout << ans << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 27644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 29 ms | 27660 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 27656 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 27648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 27676 KB | Output is correct |
2 | Incorrect | 30 ms | 27608 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 27728 KB | Output is correct |
2 | Incorrect | 376 ms | 42704 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 27732 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 27816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 152 ms | 33524 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 27800 KB | Output is correct |
2 | Correct | 38 ms | 27796 KB | Output is correct |
3 | Incorrect | 41 ms | 27848 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 232 ms | 36360 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 345 ms | 43592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 281 ms | 36100 KB | Output is correct |
2 | Incorrect | 506 ms | 42304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 671 ms | 40888 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1210 ms | 42472 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 40184 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3062 ms | 42000 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3037 ms | 42576 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3041 ms | 44372 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |