結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 09:32:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 921 ms |
| コンパイル使用メモリ | 75,944 KB |
| 最終ジャッジ日時 | 2025-01-13 06:52:35 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 |
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
void next(int& x, int& vx, int h) {
x += vx;
while (true) {
if (x < 0) {
x = -x;
} else if (x > h) {
x = h * 2 - x;
} else {
break;
}
vx = -vx;
}
}
void solve() {
int h, w, d, gx, gy, sx, sy, vx, vy;
std::cin >> h >> w >> d >>
gx >> gy >> sx >> sy >> vx >> vy;
int g = std::abs(std::gcd(vx, vy));
d *= g, vx /= g, vy /= g;
auto visited = vec(h + 1, vec(w + 1, 0));
for (int t = 0; t <= d; ++t) {
if (sx == gx && sy == gy) {
std::cout << "Hit\n";
return;
}
if (visited[sx][sy] == 4) break;
++visited[sx][sy];
next(sx, vx, h), next(sy, vy, w);
}
std::cout << "Miss\n";
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int q;
std::cin >> q;
while (q--) solve();
return 0;
}