# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491650 | valerikk | Squirrel (RMI18_squirrel) | C++17 | 4801 ms | 41664 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
const int MAX_FRACTAL_SIZE = 1024;
std::vector<std::pair<int, int>> jumps[MAX_FRACTAL_SIZE + 1];
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
jumps[1] = {{1, 0}};
for (int fractal_size = 2; fractal_size <= MAX_FRACTAL_SIZE; fractal_size *= 2) {
for (int i = 1; i <= fractal_size; ++i) {
jumps[fractal_size].emplace_back(i, 0);
}
for (int i = 1; i <= fractal_size / 2; ++i) {
jumps[fractal_size].emplace_back(fractal_size + i, i);
}
for (int i = 1; i <= fractal_size / 2; ++i) {
jumps[fractal_size].emplace_back(fractal_size + i, -i);
}
for (const auto &[x, y] : jumps[fractal_size / 2]) {
jumps[fractal_size].emplace_back(fractal_size + fractal_size / 2 + x, fractal_size / 2 + y);
jumps[fractal_size].emplace_back(fractal_size + fractal_size / 2 + x, -fractal_size / 2 + y);
jumps[fractal_size].emplace_back(fractal_size + fractal_size / 2 + y, fractal_size / 2 + x);
jumps[fractal_size].emplace_back(fractal_size + fractal_size / 2 - y, -fractal_size / 2 - x);
}
}
int N, M, F;
scanf("%d%d%d", &N, &M, &F);
int answer = 0;
while (F--) {
int x, y, fractal_size;
scanf("%d%d%d", &x, &y, &fractal_size);
--x;
--y;
answer += std::gcd(x, y) == 1;
for (const auto &[dx, dy] : jumps[fractal_size]) {
answer += std::gcd(x - dx, y - dy) == 1;
}
}
printf("%d\n", answer);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |