# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
197526 | SamAnd | Fish (IOI08_fish) | C++17 | 3089 ms | 4216 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>
using namespace std;
const int N = 500005, K = 22;
struct ban
{
int x, t;
};
bool operator<(const ban& a, const ban& b)
{
return a.x < b.x;
}
int n, k, M;
ban a[N];
int q[K][K];
int u[K];
int main()
{
scanf("%d%d%d", &n, &k, &M);
for (int i = 1; i <= n; ++i)
{
scanf("%d%d", &a[i].x, &a[i].t);
--a[i].t;
}
sort(a + 1, a + n + 1);
for (int t = 0; t < k; ++t)
{
int maxu;
for (int i = n; i >= 1; --i)
{
if (a[i].t == t)
{
maxu = a[i].x;
break;
}
}
for (int i = 1; i <= n; ++i)
{
if (a[i].x * 2 > maxu)
break;
++q[t][a[i].t];
}
++q[t][t];
}
int ans = 0;
for (int x = 1; x < (1 << k); ++x)
{
int qq = 0;
for (int i = 0; i < k; ++i)
u[i] = N;
for (int i = 0; i < k; ++i)
{
if ((x & (1 << i)))
{
++qq;
for (int j = 0; j < k; ++j)
{
if ((x & (1 << j)))
u[i] = min(u[i], q[i][j] - 1);
else
u[i] = min(u[i], q[i][j]);
}
}
}
int yans = 1;
for (int i = 0; i < k; ++i)
{
if (u[i] < 0)
yans = 0;
else
yans = (yans * 1LL * (u[i] + 1)) % M;
}
if (qq % 2 == 1)
ans = (ans + yans) % M;
else
ans = (ans - yans + M) % M;
}
ans = (ans - 1 + M) % M;
printf("%d\n", ans);
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... |