# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
369900 | arnold518 | Fish (IOI08_fish) | C++14 | 3071 ms | 25068 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 7000;
int N, K;
ll MOD;
pii B[MAXN+10];
int C[MAXN+10];
int cnt[MAXN+10];
pii P[MAXN+10];
int I[MAXN+10];
int A[MAXN+10][MAXN+10];
ll dp[MAXN+10];
int main()
{
scanf("%d%d%lld", &N, &K, &MOD);
for(int i=1; i<=N; i++) scanf("%d%d", &B[i].first, &B[i].second);
sort(B+1, B+N+1);
for(int i=1; i<=K; i++) P[i].second=i;
for(int i=1; i<=N; i++)
{
P[B[i].second].first=B[i].first;
}
sort(P+1, P+K+1);
for(int i=1; i<=K; i++) I[P[i].second]=i;
for(int i=1; i<=N; i++) B[i].second=I[B[i].second];
for(int i=1; i<=N; i++) C[B[i].second]=i;
//for(int i=1; i<=N; i++) printf("%d %d\n", B[i].first, B[i].second);
for(int i=1, j=1; i<=N; i++)
{
for(; j<=N && B[j].first*2<=B[i].first; j++)
{
cnt[B[j].second]++;
}
if(C[B[i].second]==i)
{
for(int k=1; k<=K; k++) A[B[i].second][k]=cnt[k];
}
}
for(int i=1; i<=K; i++)
{
dp[i]=dp[i-1];
ll t=1;
for(int j=1; j<=i; j++)
{
t*=A[i][j]+1;
t%=MOD;
}
dp[i]+=t;
dp[i]%=MOD;
for(int j=1; j<i; j++)
{
if(A[j][j]!=A[i][j]) continue;
t=1;
for(int k=1; k<i; k++)
{
if(k==j) continue;
t*=A[j][k]+1;
t%=MOD;
}
t*=A[j][i];
t%=MOD;
dp[i]+=t;
dp[i]%=MOD;
}
}
printf("%lld\n", dp[K]);
}
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... |