# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
369905 | arnold518 | Fish (IOI08_fish) | C++14 | 454 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5e5;
const int MAXK = 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[MAXK+10][MAXK+10];
ll dp2[MAXK+10][MAXK+10];
ll dp3[MAXK+10][MAXK+10];
ll dp[MAXK+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++)
{
dp2[i][0]=dp3[i][0]=1;
for(int j=1; j<=K; j++)
{
dp2[i][j]=dp2[i][j-1]*(A[i][j]+1)%MOD;
if(i!=j) dp3[i][j]=dp3[i][j-1]*(A[i][j]+1)%MOD;
else dp3[i][j]=dp3[i][j-1];
}
}
for(int i=1; i<=K; i++)
{
dp[i]=dp[i-1];
dp[i]+=dp2[i][i];
dp[i]%=MOD;
for(int j=1; j<i; j++)
{
if(A[j][j]!=A[i][j]) continue;
dp[i]+=A[j][i]*dp3[j][i-1];
dp[i]%=MOD;
}
}
printf("%lld\n", dp[K]);
}
컴파일 시 표준 에러 (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... |