# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
734055 |
2023-05-01T15:17:33 Z |
lorenzoferrari |
Fish (IOI08_fish) |
C++17 |
|
3000 ms |
17684 KB |
#include "bits/stdc++.h"
using namespace std;
struct fish {
int l;
int g;
bool operator<(const fish& oth) {
return l < oth.l;
}
};
signed main() {
int n; cin >> n;
int k; cin >> k;
int m; cin >> m;
vector<fish> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].l >> a[i].g; --a[i].g;
}
sort(begin(a), end(a));
vector<vector<int>> o(k);
vector<int> last(k);
for (int i = 0; i < n; ++i) {
o[a[i].g].emplace_back(a[i].l);
last[a[i].g] = i;
}
int ans = 0;
vector<int> rs;
vector<int> frq(k);
for (int r = 0, l = 0; r < n; ++r) {
int c = a[r].g;
if (last[c] != r) continue;
while (2*a[l].l <= a[r].l) {
++frq[a[l].g];
++l;
}
int cur = 1;
for (int i : rs) {
cur = (cur * (frq[i] % m + 1)) % m;
}
rs.push_back(c);
cur = cur * (frq[c] % m) % m;
int oth = 1;
for (int i = 0; i < k; ++i) {
if (i == c) continue;
if (2*o[c][frq[c]] <= o[i].back()) continue;
oth = oth * (frq[i] + 1) % m;
}
ans = (ans + cur + oth) % m;
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
351 ms |
7404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
3856 KB |
Output is correct |
2 |
Correct |
185 ms |
6812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
472 KB |
Output is correct |
2 |
Correct |
16 ms |
428 KB |
Output is correct |
3 |
Correct |
31 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
240 ms |
5248 KB |
Output is correct |
2 |
Incorrect |
400 ms |
13380 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
322 ms |
8112 KB |
Output is correct |
2 |
Correct |
432 ms |
14444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
428 ms |
5284 KB |
Output is correct |
2 |
Correct |
860 ms |
7976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1729 ms |
7972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3019 ms |
9228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3012 ms |
8744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3007 ms |
14540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3028 ms |
15300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3059 ms |
17684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |