Submission #1090280

#TimeUsernameProblemLanguageResultExecution timeMemory
1090280peacebringer1667Fish (IOI08_fish)C++17
4 / 100
111 ms16976 KiB
#include<bits/stdc++.h> #define ll long long #define ldb long double #define fi first #define se second #define sza(a) (int)a.size() #define pir pair<int,int> #define pirll pair<ll,ll> using namespace std; const int maxn = 5e5 + 5; int modu; void add(int &x,int y){ x %= modu; y %= modu; x = (x + y) % modu; } int lst[maxn],dp[maxn],pre[maxn]; pir a[maxn]; void solve(int n,int k){ int p = 0; for (int i = 1 ; i <= n ; i++){ int val = a[i].fi,type = a[i].se; while (val >= a[p].fi * 2) p++; p--; if (!lst[type]) dp[i] = (pre[p] + 1) % modu; else dp[i] = (pre[p] - pre[lst[type]]) % modu; lst[type] = p; pre[i] = (pre[i - 1] + dp[i]) % modu; } pre[n] %= modu; pre[n] += modu; pre[n] %= modu; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n,k; cin >> n >> k >> modu; for (int i = 1 ; i <= n ; i++) cin >> a[i].fi >> a[i].se; sort(a + 1,a + 1 + n); solve(n,k); cout << pre[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...