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>
using namespace std;
typedef pair<int,int> pii;
#define f first
#define s second
const int maxn = 5e5+10, maxk = 30;
int qtd[maxn][maxk], mark[maxk];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n, k, m;
cin >> n >> k >> m;
vector<pii> v(n+1);
vector<int> ans(n+1);
for(int i=1; i<=n; i++){
cin >> v[i].f >> v[i].s;
}
sort(v.begin(), v.end());
for(int i=1; i<=n; i++){
ans[i] = 1;
qtd[i][v[i].s]++;
memset(mark, 0, sizeof mark);
mark[v[i].s] = 1;
for(int j=1; j<i; j++){
if(!mark[v[j].s] and v[i].f >= v[j].f + v[j].f){
mark[v[j].s] = j;
ans[i] = (ans[i] + ans[j] - qtd[i][v[i].s] + 1)%m;
for(int q=1; q<=k; q++){
qtd[i][q] += qtd[j][q];
}
}
}
//cout << ans[i] << " " << qtd[i][v[i].s] << "\n";
}
cout << ans[n] << "\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... |