Submission #473612

#TimeUsernameProblemLanguageResultExecution timeMemory
473612OttoTheDinoFish (IOI08_fish)C++17
0 / 100
268 ms24328 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, ans = 0; 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 last[mx], cnt[mx] = {}, num[mx] = {}, done[mx] = {}, id = 0; rep (i,0,f-1) last[bois[i].se] = bois[i].fi; set<ll> st; rep (i,0,f-1) { ll l = bois[i].fi, tp = bois[i].se; while (l>=2*bois[id].fi) { ll c = ++cnt[bois[id].se]; if (done[bois[id].se]) { if (--num[c-1]==0) st.erase(c-1); if (++num[c]==1) st.insert(c); } ++id; } if (last[tp]==l) { ll res = cnt[tp]+1; for (ll el : st) res = res*(el+1)%m*num[el]%m; ans = (ans+res)%m; done[tp] = 1; if (cnt[tp] && ++num[cnt[tp]]==1) st.insert(cnt[tp]); } } 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...