結果
問題 | No.2267 群の公理 |
ユーザー |
|
提出日時 | 2023-04-14 22:17:16 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,591 bytes |
コンパイル時間 | 4,944 ms |
コンパイル使用メモリ | 76,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 13:08:27 |
合計ジャッジ時間 | 6,478 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(25, 12) Warning: imported and not used: 'sugar' [UnusedImport] /home/judge/data/code/Main.nim(23, 12) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(15, 12) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(18, 12) Warning: imported and not used: 'lists' [UnusedImport]
ソースコード
import macrosmacro Please(x): untyped = nnkStmtList.newTree()Please use Nim-ACLPlease use Nim-ACLPlease use Nim-ACL#[ include daylight/base ]#when not declared DAYLIGHT_BASE_HPP:const DAYLIGHT_BASE_HPP* = 1import systemimport macrosimport algorithmimport tablesimport setsimport listsimport intsetsimport critbitsimport sequtilsimport strutilsimport mathimport strformatimport sugarlet readToken* = iterator(oneChar: bool = false): string {.closure.}=while true:var line = stdin.readLine.splitfor s in line:if oneChar:for i in 0..<s.len():yield s[i..i]else:yield sproc read*(t: typedesc[string]): string =result = readToken()while result == "":result = readToken()proc read*(t: typedesc[int]): int = read(string).parseIntproc read*(t: typedesc[float]): float = read(string).parseFloatproc read*(t: typedesc[char]): char = readToken(true)[0]macro readSeq*(t: typedesc, n: varargs[int]): untyped =var repStr = ""for arg in n:repStr &= &"({arg.repr}).newSeqWith "parseExpr(&"{repStr}read({t})")macro read*(ts: varargs[auto]): untyped=var tupStr = ""for t in ts:tupStr &= &"read({t.repr}),"parseExpr(&"({tupStr})")macro readTupleSeq*(n: int, ts:varargs[auto]): untyped=for typ in ts:if typ.typeKind != ntyAnything:error("Expected typedesc, got " & typ.repr, typ)parseExpr(&"({n.repr}).newSeqWith read({ts.repr})")macro initSeq*(t: typedesc, n: varargs[int]): untyped =var repStr = ""for i, arg in n:if i == n.len - 1:repStr &= &"newSeq[{t}]({arg.repr}) "else:repStr &= &"({arg.repr}).newSeqWith "parseExpr(repStr)macro initSeqWith*[T](init: T, n: varargs[int]): untyped =var repStr = ""for arg in n:repStr &= &"({arg.repr}).newSeqWith "parseExpr(&"{repStr}({init})")proc `-`*(a,b: char): int = ord(a) - ord(b)proc `+`*(a: char,b: int): char = char(ord(a) + b)proc `-`*(a: char,b: int): char = char(ord(a) - b)proc `++`*(a: var int) = a += 1proc `--`*(a: var int) = a += 1proc chmin*[T](a: var T, b: T): bool {.discardable.} =if a > b:a = breturn truereturn falseproc chmax*[T](a: var T, b: T): bool {.discardable.} =if a < b:a = breturn truereturn falseconst INF* = (1e9+100).intconst LINF* = (4e18 + 100).intdiscardproc solve() =varN = read(int)A = readSeq(int,N,N)for i in 0..<N:for j in 0..<N:for k in 0..<N:if A[A[i][j]][k] != A[i][A[j][k]]:echo "No"returnvar found_e = -1for e in 0..<N:var f = truefor n in 0..<N:if A[n][e] != n or A[e][n] != n:f = falseif f:found_e = eif found_e == -1:echo "No"returnfor n in 0..<N:var flag = falsefor i in 0..<N:if A[n][i] == found_e and A[i][n] == found_e:flag = trueif not flag:echo "No"returnecho "Yes"solve()