Submission #104278

#TimeUsernameProblemLanguageResultExecution timeMemory
104278janchomathFish (IOI08_fish)C++14
0 / 100
950 ms23384 KiB
#include<bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back using namespace std; ll n,k,m,dp[500005],sum[500005],last[500005],ans,cur,raod[500005]; pair<ll,ll>a[500005]; ll pw(ll a,ll b){ ll xar = a; ll ans = 1; while(b>0){ if(b%2==1)ans=(ans*xar)%m; b/=2; xar=(xar*xar)%m; } return ans%m; } int main(){ cin >> n >> k >> m; for(int i=1; i<=n; i++){ cin >> a[i].f >> a[i].s; } sort(a+1,a+n+1); cur = 1LL; for(int i=1; i<=n; i++){ ll l = 1,r = i - 1,mid,ind = 0; while(r >= l){ mid = (l + r) / 2; if(2 * a[mid].f <= a[i].f){ l = mid + 1; ind = mid; } else { r = mid - 1; } } raod[a[i].s]++; cur = cur * pw(raod[a[i].s],m - 2LL); cur %= m; dp[i] = cur - sum[a[i].s]; dp[i] += m; dp[i] %= m; ans += dp[i]; ans %= m; sum[a[i].s] += dp[i]; sum[a[i].s] %= m; cur *= (raod[a[i].s] + 1LL); cur %= m; } cout << ans << endl; return 0; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:29:32: warning: variable 'ind' set but not used [-Wunused-but-set-variable]
         ll l = 1,r = i - 1,mid,ind = 0;
                                ^~~
#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...