Submission #6494861


Source Code Expand

Copy
import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode, queues
 
macro unpack(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  if NimMinor <= 17:
    for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
  else:
    for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
 
template input(T: typedesc, cnt: Natural = 1): untyped =
  let line = stdin.readLine.split(" ")
  when T is int:         line.map(parseInt).unpack(cnt)
  elif T is float:       line.map(parseFloat).unpack(cnt)
  elif T is string:      line.unpack(cnt)
  elif T is char:        line.mapIt(it[0]).unpack(cnt)
  elif T is seq[int]:    line.map(parseInt)
  elif T is seq[float]:  line.map(parseFloat)
  elif T is seq[string]: line
  elif T is seq[char]:   line.mapIt(it[0])
 
# proc `%=`(n: var int, m: int)  = n = n mod m
# proc `//=`(n: var int, m: int) = n = n div m
# proc `<<=`(n: var int, m: int) = n = n shl m
# proc `>>=`(n: var int, m: int) = n = n shr m
# proc `<?=`(n: var int, m: int) = n = min(n, m)
# proc `>?=`(n: var int, m: int) = n = max(n, m)
# proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
# proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))
 
# -------------------------------------------------- #

const C = 300000

var (N,K) = input(int,2)
var es = input(seq[int])

var lastEi_E = newSeq[int](C)
var prevEi_Ei = newSeq[int](N)

for ei,e in es:
  prevEi_Ei[ei] = -C
  lastEi_E[e] = -C

for ei,e in es:
  prevEi_Ei[ei] = lastEi_E[e]
  lastEi_E[e] = ei

for ei,e in es:
  if prevEi_Ei[ei] == -C:
    prevEi_Ei[ei] = lastEi_E[e] - N


var nextEi_Ei = newSeq[int](N)
for bei,e in es:
  var aei = prevEi_Ei[bei]
  if aei >= 0:
    nextEi_Ei[aei] = bei
  else:
    nextEi_Ei[aei+N] = bei+N


var S = newSeq[int]()
var i = 0
while i < N*K:
  var nextI = nextEi_Ei[i mod N] + (i div N)*N
  if nextI >= N*K:
    break
  else:
    if i!=0 and i mod N == 0:
      var shuuki = i div N
      var ryakuseru = K div shuuki
      i = (ryakuseru * shuuki)*N
      break
    else:
      i = nextI + 1


while i < N*K:
  var nextI = nextEi_Ei[i mod N] + (i div N)*N
  if nextI >= N*K:
    S.add(es[i mod N])
    i = i + 1
  else:
    i = nextI+1

for e in S:
  stdout.write(e)
  stdout.write(" ")

Submission Info

Submission Time
Task B - Do Not Duplicate
User infrub
Language Nim (0.13.0)
Score 700
Code Size 2429 Byte
Status AC
Exec Time 111 ms
Memory 20572 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: algorithm [Processing]
Hint: future [Processing]
Hint: macros [Processing]
Hint: hashes [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: etcpriv [Processing]
Hint: math [Processing]
Hint: times [Processing]
Hint: sequtils [Processing]
Hint: sets [Processing]
Hint: os [Processing]
Hint: posix [Processing]
Hint: tables [Processing]
Hint: unicode [Processing]
Hint: queues [Processing]
Hint:  [Link]
Hint: operation successful (25991 lines compiled; 2.473 sec total; 25.261MB; Release Build) [SuccessX]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 34
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt AC 2 ms 2556 KB
01-02.txt AC 17 ms 6396 KB
01-03.txt AC 19 ms 6780 KB
01-04.txt AC 55 ms 16264 KB
01-05.txt AC 13 ms 4860 KB
01-06.txt AC 66 ms 16648 KB
01-07.txt AC 63 ms 15240 KB
01-08.txt AC 46 ms 11008 KB
01-09.txt AC 70 ms 16008 KB
01-10.txt AC 77 ms 17160 KB
01-11.txt AC 55 ms 12800 KB
01-12.txt AC 35 ms 9212 KB
01-13.txt AC 49 ms 11264 KB
01-14.txt AC 41 ms 11136 KB
01-15.txt AC 68 ms 16904 KB
01-16.txt AC 66 ms 17020 KB
01-17.txt AC 63 ms 17044 KB
01-18.txt AC 66 ms 17020 KB
01-19.txt AC 78 ms 17020 KB
01-20.txt AC 78 ms 17020 KB
01-21.txt AC 74 ms 17020 KB
01-22.txt AC 86 ms 17788 KB
01-23.txt AC 90 ms 17788 KB
01-24.txt AC 88 ms 17788 KB
01-25.txt AC 108 ms 20448 KB
01-26.txt AC 106 ms 20072 KB
01-27.txt AC 100 ms 19432 KB
01-28.txt AC 74 ms 17020 KB
01-29.txt AC 76 ms 17020 KB
01-30.txt AC 111 ms 20572 KB
sample-01.txt AC 2 ms 2556 KB
sample-02.txt AC 1 ms 2556 KB
sample-03.txt AC 2 ms 2556 KB
sample-04.txt AC 2 ms 2556 KB