結果
| 問題 | No.33 アメーバがたくさん |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-16 03:16:45 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,044 bytes |
| 記録 | |
| コンパイル時間 | 3,633 ms |
| コンパイル使用メモリ | 69,532 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 05:49:10 |
| 合計ジャッジ時間 | 4,353 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'sugar' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport] /home/judge/data/code/Main.nim(1, 35) Warning: imported and not used: 'algorithm' [UnusedImport]
ソースコード
import sequtils,strutils,strscans,algorithm,math,sugar,macros
template get*():string = stdin.readLine() #.strip()
macro unpack*(rhs: seq,cnt: static[int]): auto =
let t = genSym(); result = quote do:(let `t` = `rhs`;())
for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
let
# N<100, D<10^9, T<10^9
(N,D,T) = get().split().map(parseInt).unpack(3)
X = get().split().map(parseInt)
XLR = X.mapIt((L:it-D*T,M:it,R:it+D*T))
var ans = 0
for i,x in XLR:
# other ameba range
var amebas = newSeq[tuple[L,R:int]]()
for y in XLR[0..<i]:
if abs(x.M - y.M) mod D == 0 and
(x.R >= y.L and y.R >= x.L) :
amebas &= (max(y.L,x.L), min(y.R,x.R))
# flatten
const invalid = (1,-1)
for ai,a in amebas:
for bi,b in amebas[0..<ai]:
if a.R >= b.L and b.R >= a.L and b != invalid:
amebas[ai] = (min(a.L,b.L), max(a.R,b.R))
amebas[bi] = invalid
amebas = amebas.filterIt(it != invalid)
# sub other ranges
var seg = 2 * T + 1
for a in amebas:
seg -= (a.R - a.L) div D + 1
ans += seg
echo ans