제출 #491650

#제출 시각아이디문제언어결과실행 시간메모리
491650valerikkSquirrel (RMI18_squirrel)C++17
25 / 100
4801 ms41664 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

squirrel.cpp: In function 'int main()':
squirrel.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d%d%d", &N, &M, &F);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
squirrel.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d%d%d", &x, &y, &fractal_size);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...