結果
問題 | No.3092 3-2-SAT |
ユーザー | MasKoaTS |
提出日時 | 2022-04-01 22:38:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,581 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 126,548 KB |
最終ジャッジ日時 | 2024-11-20 10:36:34 |
合計ジャッジ時間 | 6,909 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
86,336 KB |
testcase_01 | WA | - |
testcase_02 | AC | 306 ms
115,428 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 297 ms
110,352 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 124 ms
86,196 KB |
testcase_12 | AC | 129 ms
86,132 KB |
testcase_13 | AC | 128 ms
86,144 KB |
testcase_14 | AC | 128 ms
85,924 KB |
testcase_15 | AC | 126 ms
86,376 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 = [] 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)