結果
| 問題 |
No.556 仁義なきサルたち
|
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-08-12 00:18:28 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,256 bytes |
| コンパイル時間 | 891 ms |
| コンパイル使用メモリ | 64,384 KB |
| 最終ジャッジ日時 | 2024-06-30 02:07:59 |
| 合計ジャッジ時間 | 1,420 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(5, 30) Error: type mismatch: got 'seq[int]' for 'map(split(readLine(stdin), {' ', '\t', '\v', '\r', '\n', '\f'}, -1), parseInt)' but expected 'tuple'
ソースコード
import sequtils,strutils
type
unionfindtree[I : static[int]] = array[I,int]
var N,M : int
(N, M) = stdin.readline.split.map(parseInt)
var
num = newSeqWith(N + 1,1)
ut : unionfindtree[10001]
a,b : int
proc initUT[I](i : int):unionfindtree[I] =
unionfindtree[i]
proc find(U : unionfindtree; a : int, b :int): bool=
var
s = a
t = b
while s != U[s]:
s = U[s]
while t != U[t]:
t = U[t]
return s == t
proc union(U : var unionfindtree; a : int ; b : int)=
if U.find(a,b):
return
var
s = a
t = b
t2 : int
while s != U[s]:
s = U[s]
while t != U[t]:
t = U[t]
if num[s] < num[t]:
U[s] = t
num[t] += num[s]
num[s] = 0
if num[t] < num[s]:
U[t] = s
num[s] += num[t]
num[t] = 0
if num[t] == num[s]:
if t < s:
(t, s) = (s, t)
U[t] = s
num[s] += num[t]
num[t] = 0
proc root(U : unionfindtree, a :int):int=
var
s = a
while s != U[s]:
s = U[s]
return s
for i in 1..N:
ut[i] = i
for m in 1..M:
(a, b) = stdin.readline.split.map(parseInt)
ut.union(a,b)
for i in 1..N:
echo ut.root(i)
6soukiti29