# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688145 |
2023-01-27T07:54:10 Z |
finn__ |
Fish (IOI08_fish) |
C++17 |
|
340 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
size_t n, k, m;
cin >> n >> k >> m;
vector<pair<unsigned, unsigned>> fish(n);
vector<pair<unsigned, unsigned>> largest(k, {0, 0});
vector<unsigned> F(k, 0);
for (auto &[l, g] : fish)
{
cin >> l >> g;
g--;
largest[g] = max(largest[g], {l, g});
F[g] = max(F[g], l);
}
sort(fish.begin(), fish.end());
sort(largest.begin(), largest.end());
vector<unsigned> c(k);
vector<vector<unsigned>> e(k, vector<unsigned>(k));
unsigned ans = 0;
size_t p = 0;
for (size_t i = 0; i < k; i++)
{
while (p < n && 2 * fish[p].first <= largest[i].first)
{
c[fish[p].second]++;
p++;
}
for (size_t j = 0; j < k; j++)
{
e[largest[i].second][j] = c[j] % m;
}
}
for (size_t i = 0; i < k; i++)
{
unsigned x = 1, y = 1;
for (size_t j = 0; j < k; j++)
{
if (i == j)
continue;
if (!(e[j][i] >= e[i][i] + 1) && F[j] >= F[i])
y = (y * (e[i][j] + 1)) % m;
else if (F[i] > F[j])
x = (x * (e[i][j] + 1)) % m, y = (y * (e[i][j] + 1)) % m;
}
ans = (ans + x * e[i][i]) % m;
ans = (ans + y) % m;
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
123 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
2016 KB |
Output is correct |
2 |
Incorrect |
60 ms |
2404 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
16860 KB |
Output is correct |
2 |
Incorrect |
17 ms |
4340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
13172 KB |
Output is correct |
2 |
Incorrect |
201 ms |
25004 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
19992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
340 ms |
65536 KB |
Output is correct |
2 |
Runtime error |
152 ms |
65536 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
140 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
159 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
140 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
158 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
154 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
177 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |