結果

問題 No.762 PDCAパス
ユーザー むらためむらため
提出日時 2019-01-17 12:09:08
言語 Nim
(2.0.2)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 3,158 ms
コンパイル使用メモリ 67,708 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 06:56:01
合計ジャッジ時間 4,701 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 5 ms
6,944 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 11 ms
6,940 KB
testcase_25 AC 11 ms
6,940 KB
testcase_26 AC 7 ms
6,944 KB
testcase_27 AC 7 ms
6,944 KB
testcase_28 AC 12 ms
6,940 KB
testcase_29 AC 12 ms
6,944 KB
testcase_30 AC 11 ms
6,944 KB
testcase_31 AC 12 ms
6,944 KB
testcase_32 AC 11 ms
6,940 KB
testcase_33 AC 10 ms
6,944 KB
testcase_34 AC 10 ms
6,940 KB
testcase_35 AC 11 ms
6,940 KB
testcase_36 AC 9 ms
6,940 KB
testcase_37 AC 9 ms
6,944 KB
testcase_38 AC 10 ms
6,944 KB
testcase_39 AC 9 ms
6,940 KB
testcase_40 AC 9 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 54) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 47) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'sugar' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math,sugar,macros,strformat
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  var minus = false
  while true:
    var k = getchar_unlocked()
    if k == '-' : minus = true
    elif k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord
  if minus: result *= -1
let n = scan()
let m = scan()
let S = toSeq(stdin.readLine().items).mapIt:
  case it:
  of 'P':0
  of 'D':1
  of 'C':2
  else : 3
var DC = newSeq[(int,int)]()
var CA = newSeq[int]()
var ans = newSeq[int](n)
m.times:
  var u = scan() - 1
  var v = scan() - 1
  if S[u] > S[v]: (u,v) = (v,u)
  if S[v] - S[u] != 1 : continue
  case S[v]:
  of 1 : ans[v] += 1
  of 2 : DC &= (u,v)
  else : CA &= u
for dc in DC: ans[dc[1]] += ans[dc[0]]
echo CA.mapIt(ans[it]).sum() mod 1000000007
0