結果

問題 No.3311 フィルター
コンテスト
ユーザー 👑 p-adic
提出日時 2023-03-21 17:28:24
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,803 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 85,480 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-25 12:56:36
合計ジャッジ時間 3,577 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ( "O3" )
#pragma GCC optimize( "unroll-loops" )
#pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <cassert>
#include <string>
using namespace std;

#define MAIN main
#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 ## HOW_MANY_TIMES , 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 , 20 );
  CIN_ASSERT( N , 1 , bound_N );
  CEXPR( int , bound_M , 100000 );
  CIN_ASSERT( M , 1 , bound_M );
  bool inS[1 << bound_N] = {};
  int AND_S = ( 1 << N ) - 1;
  string zero = "0";
  string one = "1";
  REPEAT( M ){
    CIN( string , s );
    assert( s.size() == N );
    int n_s = 0;
    FOR( i , 0 , N ){
      string c = s.substr( i , 1 );
      n_s <<= 1;
      if( c == one ){
	n_s++;
      } else {
	assert( c == zero );
      }
    }
    assert( ! inS[n_s] );
    inS[n_s] = true;
    AND_S &= n_s;
  }
  if( AND_S == 0 || ! inS[AND_S] ){
    RETURN( "No" );
  }
  int power = 1;
  FOR( i , 0 , N ){
    if( ( AND_S & 1 ) == 0 ){
      power <<= 1;
    }
    AND_S >>= 1;
  }
  RETURN( power == M ? "Yes" : "No" );
}
0