# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688143 |
2023-01-27T07:53:41 Z |
finn__ |
Fish (IOI08_fish) |
C++17 |
|
317 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 |
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 |
0 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 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
116 ms |
4492 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 |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
2272 KB |
Output is correct |
2 |
Incorrect |
64 ms |
2636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
16900 KB |
Output is correct |
2 |
Incorrect |
15 ms |
4308 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
13308 KB |
Output is correct |
2 |
Incorrect |
216 ms |
25324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
167 ms |
20248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
65536 KB |
Output is correct |
2 |
Runtime error |
167 ms |
65536 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
141 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
153 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
132 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
156 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
155 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
188 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |