結果
問題 | No.3092 3-2-SAT |
ユーザー | MasKoaTS |
提出日時 | 2022-04-01 22:36:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,594 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 81,880 KB |
実行使用メモリ | 126,520 KB |
最終ジャッジ日時 | 2024-11-20 10:33:25 |
合計ジャッジ時間 | 7,111 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 134 ms
86,116 KB |
testcase_01 | WA | - |
testcase_02 | AC | 319 ms
115,476 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 287 ms
110,172 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 134 ms
86,132 KB |
testcase_12 | AC | 132 ms
86,272 KB |
testcase_13 | AC | 129 ms
86,232 KB |
testcase_14 | AC | 131 ms
85,868 KB |
testcase_15 | AC | 129 ms
86,020 KB |
testcase_16 | RE | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | RE | - |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] """ Main Code """ n, m = getNs() lis = [getList() for _ in [0] * m] table = [[0] * 3 for _ in [0] * n] route = [[] for _ in [0] * n] for p, q, a, b in lis: p -= 1; q -= 1 a -= 1; b -= 1 table[p][a] = table[q][b] = 1 route[p].append((q, b)) route[q].append((p, a)) ans = [0] * n que = [] #print(table) for i in range(n): cnt = 0 for j in table[i]: cnt += j if(cnt != 1): continue que.append(i) visited = [0] * n while(que): i = que.pop() if(visited[i]): continue visited[i] = True for j in range(3): if not(table[i][j]): continue ans[i] = j + 1 break for ni, t in route[i]: if(visited[ni]): continue visited[ni] = True table[ni][t] = 0 cnt = 0 for j in table[ni]: cnt += j if(cnt > 1): continue que.append(ni) for i in range(n): if(ans[i] > 0): continue for j in table[ni]: cnt += j if(cnt > 1): print(-1) exit(0) ans[i] = 1 print(*ans)