結果

問題 No.2910 単体ホモロジー入門
ユーザー 👑 p-adicp-adic
提出日時 2023-09-08 14:50:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,597 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 208,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 08:38:13
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:107:38: warning: 'end0' may be used uninitialized [-Wmaybe-uninitialized]
  107 |           if( end3 != start0 || end3 == end0 ){
      |                                 ~~~~~^~~~~~~
main.cpp:52:11: note: 'end0' was declared here
   52 |       int end0;
      |           ^~~~
main.cpp:107:20: warning: 'start0' may be used uninitialized [-Wmaybe-uninitialized]
  107 |           if( end3 != start0 || end3 == end0 ){
      |               ~~~~~^~~~~~~~~
main.cpp:51:11: note: 'start0' was declared here
   51 |       int start0;
      |           ^~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE 
#define CIN( LL , A ) LL A; cin >> A 
#define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) ) 
#define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) 
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) 
#define QUIT return 0 
#define COUT( ANSWER ) cout << ( ANSWER ) << "\n"; 
#define RETURN( ANSWER ) COUT( ANSWER ); QUIT 

int main()
{
  UNTIE;
  CEXPR( int , bound_N , 4 );
  CIN_ASSERT( N , 1 , bound_N );
  if( N < 3 ){
    RETURN( "No" );
  }
  CEXPR( int , bound_M , ( bound_N * ( bound_N - 1 ) ) / 2 );
  CIN_ASSERT( M , 0 , bound_M );
  if( M < 3 ){
    RETURN( "No" );
  }
  int ij[bound_M][2];
  FOR( m , 0 , M ){
    CIN( int , im );
    CIN( int , jm );
    assert( 0 <= im && im < jm && jm < N );
    FOR( k , 0 , m ){
      assert( ij[k][0] != im || ij[k][1] != jm );
    }
    ij[m][0] = im;
    ij[m][1] = jm;
  }
  set<int> vertex_exception{};
  REPEAT( 3 ){
    CIN_ASSERT( v , 0 , N - 1 );
    vertex_exception.insert( v );
  }
  FOR( m0 , 0 , M ){
    FOR( m1 , 0 , M ){
      if( m0 == m1 ){
	continue;
      }
      int count1 = 0;
      int start0;
      int end0;
      int end1;
      FOR( s , 0 , 2 ){
	FOR( t , 0 , 2 ){
	  if( ij[m0][s] == ij[m1][t] ){
	    count1++;
	    start0 = ij[m0][1-s];
	    end0 = ij[m0][s];
	    end1 = ij[m1][1-t];
	  }
	}
      }
      if( count1 != 1 ){
	continue;
      }
      FOR( m2 , 0 , M ){
	if( m0 == m2 || m1 == m2 ){
	  continue;
	}
	int count2 = 0;
	int end2;
	FOR( t , 0 , 2 ){
	  if( end1 == ij[m2][t] ){
	    count2++;
	    end2 = ij[m2][1-t];
	  }
	}
	if( count2 != 1 ){
	  continue;
	}
	if( end2 == start0 ){
	  set<int> vertex{ end0 , end1 , end2 };
	  if( vertex != vertex_exception ){
	    RETURN( "Yes" );
	  }
	  continue;
	}
	if( N == 3 ){
	  continue;
	}
	FOR( m3 , 0 , M ){
	  if( m0 == m3 || m1 == m3 || m2 == m3 ){
	    continue;
	  }
	  int count3 = 0;
	  int end3;
	  FOR( t , 0 , 2 ){
	    if( end2 == ij[m3][t] ){
	      count3++;
	      end3 = ij[m3][1-t];
	    }
	  }
	  if( count3 != 1 ){
	    continue;
	  }
	  if( end3 != start0 || end3 == end0 ){
	    continue;
	  }
	  RETURN( "Yes" );
	}
      }
    }
  }
  RETURN( "No" );
}
0