# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
989581 |
2024-05-28T10:53:28 Z |
huutuan |
Fish (IOI08_fish) |
C++14 |
|
3000 ms |
65536 KB |
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
int n, m, mod;
pair<int, int> a[N];
int solve(vector<pair<int, int>> v){
if (v.empty()) return 0;
int z=v.back().second;
vector<int> cnt(m+1), cnt2(m+1);
for (auto &i:v) if (i.first*2<=v.back().first) ++cnt[i.second];
int ans=accumulate(cnt.begin(), cnt.end(), 1ll, [&](int x, int y){ return x*(y+1)%mod; });
vector<int> lst(m+1);
for (int i=0; i<(int)v.size(); ++i) lst[v[i].second]=i;
for (int i=0, j=-1; i<(int)v.size(); ++i){
while (v[j+1].first*2<=v[i].first){
++j;
++cnt2[v[j].second];
}
if (v[i].second!=z && cnt2[v[i].second]>=cnt[v[i].second] && lst[v[i].second]==i){
int prod=(cnt2[v[i].second]-cnt[v[i].second]+1);
for (int k=1; k<=m; ++k) if (k!=v[i].second) prod=prod*(cnt2[k]+1-(k==z))%mod;
ans=(ans+prod)%mod;
}
}
vector<pair<int, int>> v2;
for (auto &i:v) if (i.second!=z) v2.push_back(i);
return (ans+solve(v2))%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> mod;
for (int i=1; i<=n; ++i) cin >> a[i].first >> a[i].second;
sort(a+1, a+n+1);
cout << solve(vector<pair<int, int>>(a+1, a+n+1)) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
200 ms |
65536 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
107 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3057 ms |
10660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
196 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
142 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
595 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3059 ms |
57888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
24384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3065 ms |
7156 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3042 ms |
9044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3073 ms |
9044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3027 ms |
10576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |