# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688142 |
2023-01-27T07:48:22 Z |
finn__ |
Fish (IOI08_fish) |
C++17 |
|
354 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 (!(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 |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 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 |
120 ms |
4356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
2020 KB |
Output is correct |
2 |
Incorrect |
78 ms |
2532 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
16852 KB |
Output is correct |
2 |
Incorrect |
19 ms |
4420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
13048 KB |
Output is correct |
2 |
Incorrect |
220 ms |
25188 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
183 ms |
19876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
354 ms |
65536 KB |
Output is correct |
2 |
Runtime error |
164 ms |
65536 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
143 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 |
163 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 |
166 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
180 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |