結果

問題 No.61 リベリオン
ユーザー furafura
提出日時 2020-06-14 10:17:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 585 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 198,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 08:23:42
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 39 ms
4,376 KB
testcase_04 AC 39 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int q; cin>>q;
	rep(_,q){
		int w,h,d,sx,sy,gx,gy,vx,vy;
		cin>>w>>h>>d>>gx>>gy>>sx>>sy>>vx>>vy;

		int g=gcd(vx,vy);
		d*=g;
		int dx=vx/g;
		int dy=vy/g;

		bool vis[30][30]={};
		int x=sx,y=sy;
		while(d>=0 && !vis[y][x]){
			vis[y][x]=true;
			y=(y+dy)%(2*h); if(y<0) y+=2*h;
			x=(x+dx)%(2*w); if(x<0) x+=2*w;
			d--;
		}
		puts(vis[gy][gx]
		   ||vis[gy][(2*w-gx)%(2*w)]
		   ||vis[(2*h-gy)%(2*h)][gx]
		   ||vis[(2*h-gy)%(2*h)][(2*w-gx)%(2*w)]?"Hit":"Miss");
	}

	return 0;
}
0