結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-30 10:19:32 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,530 bytes |
| コンパイル時間 | 1,758 ms |
| コンパイル使用メモリ | 70,160 KB |
| 最終ジャッジ日時 | 2024-11-14 20:10:26 |
| 合計ジャッジ時間 | 2,166 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(21, 1) template/generic instantiation of `main` from here /home/judge/data/code/Main.nim(2, 52) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(21, 1) template/generic instantiation of `main` from here /home/judge/data/code/Main.nim(2, 64) Error: cannot open file: queues
ソースコード
template main(MAIN_BODY:untyped):untyped =
import sequtils,strutils,strscans,algorithm,math,future,sets,queues,tables
template get():string = stdin.readLine()
template times(n:int,body:untyped): untyped = (for _ in 0..<n: body)
template rep(i:untyped,n:int,body:untyped):untyped =
block:(var i = 0; while i < n:( body; i += 1))
template each[T](arr:var seq[T],elem,body:untyped):untyped =
for _ in 0..<arr.len:(proc (elem:var T):auto = body)(arr[_])
template `+=`(x,y:typed):void = x = x + y
template `-=`(x,y:typed):void = x = x - y
template `*=`(x,y:typed):void = x = x * y
template `/=`(x,y:typed):void = x = x / y
template `%=`(x,y:typed):void = x = x mod y
template `//=`(x,y:typed):void = x = x div y
proc popcount(n:int):cint{.importC: "__builtin_popcount", noDecl .} # sum of "1"
proc clz(n:int):cint{.importC: "__builtin_clz", noDecl .} # <0000>10 -> 4
proc ctz(n:int):cint{.importC: "__builtin_ctz", noDecl .} # 01<0000> -> 4
if isMainModule:
MAIN_BODY
main:
let
N = get().parseInt
ws = get().split().map(parseInt)
goal = ws.sum() div 2
if ws.sum() mod 2 == 1 :
echo "impossible"
quit()
var dp = newSeqWith(goal+1,newSeqWith(N,false))
proc dfs(x,i:int):void =
if dp[x][i]:
return
if x == 0 or (i == N-1 and x - ws[i] == 0):
echo "possible"
quit()
if i == N - 1:
dp[x][i] = true
return
if x - ws[i] >= 0:
dfs(x - ws[i],i+1)
dfs(x,i+1)
dp[x][i] = true
dfs(goal,0)
echo "impossible"