This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |