結果

問題 No.488 四角関係
ユーザー 0w10w1
提出日時 2017-04-09 19:50:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,024 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2023-09-25 01:29:56
合計ジャッジ時間 9,520 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 534 ms
79,044 KB
testcase_01 AC 457 ms
79,588 KB
testcase_02 AC 513 ms
79,320 KB
testcase_03 AC 309 ms
79,264 KB
testcase_04 AC 386 ms
79,564 KB
testcase_05 AC 632 ms
79,808 KB
testcase_06 AC 871 ms
79,340 KB
testcase_07 AC 1,024 ms
80,640 KB
testcase_08 AC 676 ms
77,544 KB
testcase_09 AC 71 ms
71,360 KB
testcase_10 AC 259 ms
79,364 KB
testcase_11 AC 135 ms
78,068 KB
testcase_12 AC 226 ms
79,236 KB
testcase_13 AC 252 ms
79,336 KB
testcase_14 AC 182 ms
78,808 KB
testcase_15 AC 94 ms
77,332 KB
testcase_16 AC 76 ms
75,976 KB
testcase_17 AC 72 ms
71,516 KB
testcase_18 AC 86 ms
76,464 KB
testcase_19 AC 107 ms
77,720 KB
testcase_20 AC 84 ms
76,372 KB
testcase_21 AC 73 ms
71,176 KB
testcase_22 AC 83 ms
76,304 KB
testcase_23 AC 76 ms
76,208 KB
testcase_24 AC 95 ms
76,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map( int, input().split() )
adj = [ [ 0 for i in range( N ) ] for j in range( N ) ]
for i in range( M ):
  u, v = map( int, input().split() )
  adj[ u ][ v ] = 1
  adj[ v ][ u ] = 1
bag = set()
for i in range( N ):
  for j in range( N ):
    for k in range( N ):
      for l in range( N ):
        qq = set()
        qq.add( i )
        qq.add( j )
        qq.add( k )
        qq.add( l )
        if len( qq ) != 4: continue
        if adj[ i ][ j ] and adj[ j ][ k ] and adj[ i ][ k ]: continue
        if adj[ j ][ k ] and adj[ k ][ l ] and adj[ l ][ j ]: continue
        if adj[ i ][ k ] and adj[ k ][ l ] and adj[ l ][ i ]: continue
        if adj[ i ][ j ] and adj[ j ][ l ] and adj[ l ][ i ]: continue
        if adj[ i ][ j ] and adj[ j ][ k ] and adj[ k ][ l ] and adj[ l ][ i ]:
          f = sorted( [ i, j, k, l ] )
          bag.add( ( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] ) )
print( len( bag ) )
0