Submission #473444

#TimeUsernameProblemLanguageResultExecution timeMemory
473444OttoTheDinoFish (IOI08_fish)C++17
0 / 100
313 ms28156 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,s,e) for (ll i = s; i <= e; ++i) #define pb push_back #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ii> vii; const ll mx = 5e5+5; int main() { ios::sync_with_stdio(0); cin.tie(0); ll f, k, m; cin >> f >> k >> m; vii bois; rep (i,0,f-1) { ll l, tp; cin >> l >> tp; bois.pb({l, tp}); } sort(all(bois)); ll id = 0, cnt[mx] = {}, num[mx], ans = 0, been[mx] = {}; set<ll> st; for (ii boi : bois) { ll l = boi.fi, tp = boi.se, g = !been[tp]; while (l >= 2*bois[id].fi) { if (--num[cnt[bois[id].se]]==0) st.erase(cnt[bois[id].se]); if (num[++cnt[bois[id].se]]++==0) st.insert(cnt[bois[id].se]); if (bois[id].se==tp) g++; id++; } ll res = 1; for (ll el : st) res = res*el*num[el]%m; ans = (ans+res*g)%m; been[tp] = 1; } cout << ans << "\n"; return 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...