結果
| 問題 | No.643 Two Operations No.2 |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-07-13 10:56:28 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 1,054 ms |
| コンパイル使用メモリ | 29,952 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 15:56:00 |
| 合計ジャッジ時間 | 1,145 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
ソースコード
// yukicoder: No.643 Two Operations No.2
// 2019.7.13 bal4u
#include <stdio.h>
#define SFT 500
#define MAX 1000
#define ABS(x) ((x)>=0?(x):-(x))
typedef struct { int x, y, s; } Q;
Q q[100000]; int top, end;
char vis[MAX+2][MAX+2];
int main()
{
int x, y, s, ans = -1;
scanf("%d%d", &x, &y);
q[0].x = x, q[0].y = y, end = 1;
while (top != end) {
x = q[top].x, y = q[top].y, s = q[top++].s;
if (x == y) { ans = s; break; }
if (vis[SFT+x][SFT+y]) continue;
vis[SFT+x][SFT+y] = 1;
q[end].x = y, q[end].y = x, q[end++].s = s+1;
if (ABS(x+y) <= SFT && ABS(x-y) <= SFT)
q[end].x = x+y, q[end].y = x-y, q[end++].s = s+1;
}
printf("%d\n", ans);
return 0;
}
bal4u