Submission #7917160


Source Code Expand

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

"""
・マッチング、と見せかけて、2辺を組にして取っていく。
・これは、連結成分上の辺の数が偶数ならできる。例えば全域木をとって根から遠い葉のまわりから処理していく。
・「1辺除いたとき、辺の数が奇数であるような連結成分ありますか?」に答える
・辺が奇数個の連結成分が唯一のときだけが問題。そのときは橋の検出アルゴリズム
"""

N = int(readline())
m = map(int,read().split())
X = []; Y = []
for x,y in zip(m,m):
    X.append(x-1)
    Y.append(y+N+N)

# とりあえず連結成分に分ける
_,comp = connected_components(csr_matrix(([1]*(N+N+1),(X,Y)),(4*N+2,4*N+2)))

comp_size = [0] * (4*N+2) # 「成分内の辺の個数」
for x,y in zip(X,Y):
    comp_size[comp[x]] += 1

comp_size

odd_comp = [i for i,x in enumerate(comp_size) if x&1]

if len(odd_comp) > 1:
    print('\n'.join('NG' for _ in range(N+N+1)))
    exit()

raise Exception

Submission Info

Submission Time
Task D - みんな仲良し高橋君
User maspy
Language Python (3.4.3)
Score 0
Code Size 1234 Byte
Status RE
Exec Time 618 ms
Memory 52204 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 30 0 / 70
Status
RE × 3
RE × 15
AC × 6
RE × 42
Set Name Test Cases
Sample example_0.txt, example_1.txt, example_2.txt
Subtask1 bone_bubun_0.txt, bone_bubun_1.txt, bone_bubun_2.txt, komakai_bubun_0.txt, komakai_bubun_1.txt, komakai_bubun_2.txt, maxrand_bubun_0.txt, maxrand_bubun_1.txt, random_bubun_0.txt, random_bubun_1.txt, smallrand_bubun_0.txt, smallrand_bubun_1.txt, smallrand_bubun_2.txt, square_bubun_0.txt, square_bubun_1.txt
All bone_0.txt, bone_1.txt, bone_2.txt, bone_bubun_0.txt, bone_bubun_1.txt, bone_bubun_2.txt, example_0.txt, example_1.txt, example_2.txt, handmade_0.txt, handmade_1.txt, handmade_2.txt, handmade_3.txt, komakai_0.txt, komakai_1.txt, komakai_2.txt, komakai_bubun_0.txt, komakai_bubun_1.txt, komakai_bubun_2.txt, maxrand_0.txt, maxrand_1.txt, maxrand_bubun_0.txt, maxrand_bubun_1.txt, random_0.txt, random_1.txt, random_bubun_0.txt, random_bubun_1.txt, renket_0.txt, renket_1.txt, smallrand_0.txt, smallrand_1.txt, smallrand_bubun_0.txt, smallrand_bubun_1.txt, smallrand_bubun_2.txt, square_0.txt, square_1.txt, square_bubun_0.txt, square_bubun_1.txt, supersmall_0.txt, supersmall_1.txt, threeren_0.txt, threeren_1.txt, treebase_0.txt, treebase_1.txt, treebase_2.txt, example_0.txt, example_1.txt, example_2.txt
Case Name Status Exec Time Memory
bone_0.txt RE 618 ms 52204 KB
bone_1.txt RE 486 ms 47636 KB
bone_2.txt RE 481 ms 47536 KB
bone_bubun_0.txt RE 254 ms 22116 KB
bone_bubun_1.txt RE 176 ms 14720 KB
bone_bubun_2.txt RE 281 ms 25012 KB
example_0.txt RE 166 ms 13704 KB
example_1.txt RE 166 ms 13732 KB
example_2.txt RE 166 ms 13732 KB
handmade_0.txt RE 166 ms 13732 KB
handmade_1.txt RE 168 ms 13732 KB
handmade_2.txt RE 166 ms 13732 KB
handmade_3.txt RE 167 ms 13732 KB
komakai_0.txt RE 519 ms 51708 KB
komakai_1.txt RE 501 ms 51804 KB
komakai_2.txt RE 497 ms 51804 KB
komakai_bubun_0.txt RE 498 ms 51708 KB
komakai_bubun_1.txt RE 491 ms 51804 KB
komakai_bubun_2.txt RE 496 ms 51804 KB
maxrand_0.txt AC 527 ms 51804 KB
maxrand_1.txt AC 538 ms 51708 KB
maxrand_bubun_0.txt RE 511 ms 50780 KB
maxrand_bubun_1.txt RE 520 ms 51708 KB
random_0.txt AC 177 ms 15112 KB
random_1.txt AC 382 ms 35428 KB
random_bubun_0.txt RE 180 ms 15016 KB
random_bubun_1.txt RE 264 ms 24340 KB
renket_0.txt RE 520 ms 51708 KB
renket_1.txt RE 524 ms 51708 KB
smallrand_0.txt AC 168 ms 13736 KB
smallrand_1.txt AC 167 ms 13704 KB
smallrand_bubun_0.txt RE 166 ms 13736 KB
smallrand_bubun_1.txt RE 168 ms 13732 KB
smallrand_bubun_2.txt RE 167 ms 13732 KB
square_0.txt RE 481 ms 49388 KB
square_1.txt RE 488 ms 49700 KB
square_bubun_0.txt RE 498 ms 50020 KB
square_bubun_1.txt RE 389 ms 40596 KB
supersmall_0.txt RE 165 ms 13732 KB
supersmall_1.txt RE 166 ms 13704 KB
threeren_0.txt RE 502 ms 51708 KB
threeren_1.txt RE 504 ms 51708 KB
treebase_0.txt RE 440 ms 43892 KB
treebase_1.txt RE 227 ms 20572 KB
treebase_2.txt RE 370 ms 37180 KB