結果

問題 No.488 四角関係
コンテスト
ユーザー 0w1
提出日時 2017-04-09 19:50:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 694 ms / 5,000 ms
コード長 911 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 173 ms
コンパイル使用メモリ 85,164 KB
実行使用メモリ 156,628 KB
最終ジャッジ日時 2026-04-01 16:59:44
合計ジャッジ時間 5,858 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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