結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
kemuniku
|
| 提出日時 | 2025-01-25 13:37:19 |
| 言語 | Nim (2.2.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 4,366 bytes |
| コンパイル時間 | 3,866 ms |
| コンパイル使用メモリ | 76,288 KB |
| 実行使用メモリ | 25,984 KB |
| 平均クエリ数 | 2.64 |
| 最終ジャッジ日時 | 2025-01-25 22:52:25 |
| 合計ジャッジ時間 | 6,766 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge8 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 RE * 1 |
ソースコード
import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2])
ImportExpand "cplib/tmpl/sheep.nim" <=== "when not declared CPLIB_TMPL_SHEEP:\n const CPLIB_TMPL_SHEEP* = 1\n {.warning[UnusedImport]: off.}\n {.hint[XDeclaredButNotUsed]: off.}\n import algorithm\n import sequtils\n import tables\n import macros\n import math\n import sets\n import strutils\n import strformat\n import sugar\n import heapqueue\n import streams\n import deques\n import bitops\n import std/lenientops\n import options\n #入力系\n proc scanf(formatstr: cstring){.header: \"<stdio.h>\", varargs.}\n proc getchar(): char {.importc: \"getchar_unlocked\", header: \"<stdio.h>\", discardable.}\n proc ii(): int {.inline.} = scanf(\"%lld\\n\", addr result)\n proc lii(N: int): seq[int] {.inline.} = newSeqWith(N, ii())\n proc si(): string {.inline.} =\n result = \"\"\n var c: char\n while true:\n c = getchar()\n if c == ' ' or c == '\\n' or c == '\\255':\n break\n result &= c\n #chmin,chmax\n template `max=`(x, y) = x = max(x, y)\n template `min=`(x, y) = x = min(x, y)\n #bit演算\n proc `%`*(x: int, y: int): int =\n result = x mod y\n if y > 0 and result < 0: result += y\n if y < 0 and result > 0: result += y\n proc `//`*(x: int, y: int): int{.inline.} =\n result = x div y\n if y > 0 and result * y > x: result -= 1\n if y < 0 and result * y < x: result -= 1\n proc `%=`(x: var int, y: int): void = x = x%y\n proc `//=`(x: var int, y: int): void = x = x//y\n proc `**`(x: int, y: int): int = x^y\n proc `**=`(x: var int, y: int): void = x = x^y\n proc `^`(x: int, y: int): int = x xor y\n proc `|`(x: int, y: int): int = x or y\n proc `&`(x: int, y: int): int = x and y\n proc `>>`(x: int, y: int): int = x shr y\n proc `<<`(x: int, y: int): int = x shl y\n proc `~`(x: int): int = not x\n proc `^=`(x: var int, y: int): void = x = x ^ y\n proc `&=`(x: var int, y: int): void = x = x & y\n proc `|=`(x: var int, y: int): void = x = x | y\n proc `>>=`(x: var int, y: int): void = x = x >> y\n proc `<<=`(x: var int, y: int): void = x = x << y\n proc `[]`(x: int, n: int): bool = (x and (1 shl n)) != 0\n #便利な変換\n proc `!`(x: char, a = '0'): int = int(x)-int(a)\n #定数\n #[ include cplib/utils/constants ]#\n when not declared CPLIB_UTILS_CONSTANTS:\n const CPLIB_UTILS_CONSTANTS* = 1\n const INF32*: int32 = 100100111.int32\n const INF64*: int = int(3300300300300300491)\n const INF = INF64\n #converter\n\n #range\n iterator range(start: int, ends: int, step: int): int =\n var i = start\n if step < 0:\n while i > ends:\n yield i\n i += step\n elif step > 0:\n while i < ends:\n yield i\n i += step\n iterator range(ends: int): int = (for i in 0..<ends: yield i)\n iterator range(start: int, ends: int): int = (for i in\n start..<ends: yield i)\n\n #joinが非stringでめちゃくちゃ遅いやつのパッチ\n proc join*[T: not string](a: openArray[T], sep: string = \"\"): string = a.mapit($it).join(sep)\n\n proc dump[T](arr:seq[seq[T]])=\n for i in 0..<len(arr):\n echo arr[i]\n"
# 3回聞くと,当然特定が可能
# ところで、それよりも小さい回数で特定が可能である例がある。
# たとえば、H = 1のとき、(1,1)からの距離を聞くことで1回の質問で宝物の場所を特定することができる。
# 右上と左上から聞けば、一意に特定できる。
var tmp = stdin.readline().split(" ").mapit(parseInt(it))
var H = tmp[0]
var W = tmp[1]
echo "? ",1," ",1
var d1 = stdin.readLine().parseInt()
var kouho : seq[(int,int)]
for i in 1..H:
for j in 1..W:
if (i-1)**2 + (j-1)**2 == d1:
kouho.add((i,j))
if len(kouho) == 1:
echo "! ",kouho[0][0]," ",kouho[0][1]
quit()
echo "? ",1," ",W
var d2 = stdin.readLine().parseInt()
var kouho2 : seq[(int,int)]
for (i,j) in kouho:
if (i-1)**2 + (j-W)**2 == d2:
kouho2.add((i,j))
if len(kouho2) == 1:
echo "! ",kouho2[0][0]," ",kouho2[0][1]
quit()
kemuniku