# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011967 |
2024-07-01T12:53:41 Z |
thinknoexit |
Fish (IOI08_fish) |
C++17 |
|
224 ms |
19704 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 500500;
ll MOD;
int n;
pair<int, int> a[N];
ll tree[4 * N];
int cnt[N], mx[N];
bool ch[N];
void build(int now = 1, int l = 1, int r = n) {
tree[now] = 1;
if (l == r) return;
int mid = (l + r) / 2;
build(2 * now, l, mid), build(2 * now + 1, mid + 1, r);
}
void update(int v, int w, int now = 1, int l = 1, int r = n) {
if (l == r) {
tree[now] = (tree[now] + w) % MOD;
return;
}
int mid = (l + r) / 2;
if (v <= mid) update(v, w, 2 * now, l, mid);
else update(v, w, 2 * now + 1, mid + 1, r);
tree[now] = tree[2 * now] * tree[2 * now + 1] % MOD;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int m;
cin >> m >> n >> MOD;
for (int i = 1;i <= m;i++) {
cin >> a[i].first >> a[i].second;
mx[a[i].second] = max(mx[a[i].second], a[i].first);
}
vector<pair<int, int>> v;
for (int i = 1;i <= n;i++) {
v.push_back({ mx[i], i });
}
sort(v.begin(), v.end());
sort(a + 1, a + 1 + m);
build();
ll ans = 0;
int p = 0;
for (int i = 1;i <= n;i++) {
int l, t;
tie(l, t) = v[i - 1];
while (p < m && a[p + 1].first * 2 <= l) {
p++;
cnt[a[p].second]++;
if (ch[a[p].second]) update(a[p].second, 1);
}
update(t, cnt[t] % MOD);
ch[t] = 1;
ans = (ans + tree[1]) % MOD;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
476 KB |
Output is correct |
2 |
Incorrect |
94 ms |
10336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
4148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
628 KB |
Output is correct |
3 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
6124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
9180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
6480 KB |
Output is correct |
2 |
Incorrect |
106 ms |
11624 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
100 ms |
11004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
123 ms |
12568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
12136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
173 ms |
17708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
167 ms |
16328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
224 ms |
19704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |