Submission #369900

#TimeUsernameProblemLanguageResultExecution timeMemory
369900arnold518Fish (IOI08_fish)C++14
32 / 100
3071 ms25068 KiB
#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)

fish.cpp: In function 'int main()':
fish.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |  scanf("%d%d%lld", &N, &K, &MOD);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:26:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |  for(int i=1; i<=N; i++) scanf("%d%d", &B[i].first, &B[i].second);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...