# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677778 | vjudge1 | Fish (IOI08_fish) | C++17 | 325 ms | 45024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 1e6+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 22;
const int off = 1 << logo;
const int treesiz = off << 1;
int n, k, m;
pair<int, int> niz[maxn];
int cnt[maxn];
int tour[treesiz];
int mul(int a, int b) {
a %= m, b %= m;
return (a * b) % m;
}
void update(int x, int val) {
x += off;
tour[x] += val;
x /= 2;
while (x > 0) tour[x] = mul(tour[x * 2], tour[x * 2 + 1]), x /= 2;
}
int main() {
scanf("%d%d%d", &n, &k, &m);
for (int i = 0; i < n; i++) {
int a, b;
scanf("%d%d", &a, &b);
niz[i] = {a, b};
}
sort(niz, niz+n);
for (int i = 0; i < treesiz; i++) tour[i] = 1;
int sol = 0;
int ptr = 0;
for (int i = 0; i < n; i++) {
if (i == 0 || niz[i].X != niz[i - 1].X) sol += mul(tour[1], (n - ptr)), sol %= mod;
update(niz[i].Y, 1);
while (ptr < n && niz[ptr].X < 2 * niz[i].X) ptr++;
}
printf("%d\n", sol);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |