#include #include #include #include #include using namespace std; #define TYPE_OF( VAR ) remove_const::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 , 16 ); CIN_ASSERT( N , 1 , bound_N ); CEXPR( int , bound_M , 1 << 12 ); CIN_ASSERT( M , 1 , N < 12 ? 1 << N : bound_M ); bool O[1 << bound_N] = {}; int s[bound_M] = {}; string one = "1"; FOR( m , 0 , M ){ int& s_m = s[m]; CIN( string , s_bit ); FOR( n , 0 , N ){ ( s_m <<= 1 ) |= ( s_bit.substr( n , 1 ) == one ? 1 : 0 ); } assert( !( O[s_m] ) ); O[s_m] = true; } if( ! O[0] ){ RETURN( "No" ); } if( ! O[ ( 1 << N ) - 1 ] ){ RETURN( "No" ); } FOR( m0 , 1 , M ){ int& sm0 = s[m0]; FOR( m1 , 0 , m0 ){ int& sm1 = s[m1]; if( ! O[ sm0 & sm1 ] || ! O[ sm0 | sm1 ] ){ RETURN( "No" ); } } } RETURN( "Yes" ); }