結果
問題 | No.5005 3-SAT |
ユーザー | 👑 p-adic |
提出日時 | 2022-08-20 08:47:37 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 339 ms / 2,000 ms |
コード長 | 5,917 bytes |
コンパイル時間 | 1,092 ms |
実行使用メモリ | 3,596 KB |
スコア | 48,964 |
最終ジャッジ日時 | 2022-08-20 08:47:57 |
合計ジャッジ時間 | 18,075 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 141 ms
3,420 KB |
testcase_01 | AC | 254 ms
3,580 KB |
testcase_02 | AC | 99 ms
3,576 KB |
testcase_03 | AC | 128 ms
3,580 KB |
testcase_04 | AC | 73 ms
3,568 KB |
testcase_05 | AC | 86 ms
3,408 KB |
testcase_06 | AC | 266 ms
3,580 KB |
testcase_07 | AC | 139 ms
3,564 KB |
testcase_08 | AC | 108 ms
3,472 KB |
testcase_09 | AC | 115 ms
3,564 KB |
testcase_10 | AC | 79 ms
3,412 KB |
testcase_11 | AC | 132 ms
3,492 KB |
testcase_12 | AC | 49 ms
3,516 KB |
testcase_13 | AC | 76 ms
3,488 KB |
testcase_14 | AC | 78 ms
3,520 KB |
testcase_15 | AC | 59 ms
3,516 KB |
testcase_16 | AC | 157 ms
3,584 KB |
testcase_17 | AC | 161 ms
3,416 KB |
testcase_18 | AC | 71 ms
3,480 KB |
testcase_19 | AC | 87 ms
3,416 KB |
testcase_20 | AC | 115 ms
3,416 KB |
testcase_21 | AC | 54 ms
3,588 KB |
testcase_22 | AC | 54 ms
3,584 KB |
testcase_23 | AC | 189 ms
3,532 KB |
testcase_24 | AC | 68 ms
3,456 KB |
testcase_25 | AC | 102 ms
3,528 KB |
testcase_26 | AC | 123 ms
3,596 KB |
testcase_27 | AC | 43 ms
3,580 KB |
testcase_28 | AC | 274 ms
3,484 KB |
testcase_29 | AC | 134 ms
3,500 KB |
testcase_30 | AC | 159 ms
3,572 KB |
testcase_31 | AC | 118 ms
3,460 KB |
testcase_32 | AC | 159 ms
3,596 KB |
testcase_33 | AC | 67 ms
3,464 KB |
testcase_34 | AC | 77 ms
3,428 KB |
testcase_35 | AC | 179 ms
3,572 KB |
testcase_36 | AC | 137 ms
3,416 KB |
testcase_37 | AC | 128 ms
3,424 KB |
testcase_38 | AC | 38 ms
3,504 KB |
testcase_39 | AC | 74 ms
3,408 KB |
testcase_40 | AC | 60 ms
3,476 KB |
testcase_41 | AC | 47 ms
3,400 KB |
testcase_42 | AC | 75 ms
3,416 KB |
testcase_43 | AC | 112 ms
3,492 KB |
testcase_44 | AC | 169 ms
3,420 KB |
testcase_45 | AC | 81 ms
3,476 KB |
testcase_46 | AC | 136 ms
3,468 KB |
testcase_47 | AC | 69 ms
3,504 KB |
testcase_48 | AC | 102 ms
3,416 KB |
testcase_49 | AC | 178 ms
3,484 KB |
testcase_50 | AC | 67 ms
3,512 KB |
testcase_51 | AC | 81 ms
3,528 KB |
testcase_52 | AC | 140 ms
3,588 KB |
testcase_53 | AC | 198 ms
3,432 KB |
testcase_54 | AC | 68 ms
3,564 KB |
testcase_55 | AC | 157 ms
3,424 KB |
testcase_56 | AC | 175 ms
3,492 KB |
testcase_57 | AC | 81 ms
3,460 KB |
testcase_58 | AC | 120 ms
3,468 KB |
testcase_59 | AC | 146 ms
3,480 KB |
testcase_60 | AC | 69 ms
3,408 KB |
testcase_61 | AC | 134 ms
3,484 KB |
testcase_62 | AC | 83 ms
3,416 KB |
testcase_63 | AC | 89 ms
3,564 KB |
testcase_64 | AC | 149 ms
3,540 KB |
testcase_65 | AC | 132 ms
3,412 KB |
testcase_66 | AC | 63 ms
3,580 KB |
testcase_67 | AC | 50 ms
3,408 KB |
testcase_68 | AC | 85 ms
3,412 KB |
testcase_69 | AC | 231 ms
3,524 KB |
testcase_70 | AC | 339 ms
3,428 KB |
testcase_71 | AC | 164 ms
3,484 KB |
testcase_72 | AC | 100 ms
3,552 KB |
testcase_73 | AC | 185 ms
3,484 KB |
testcase_74 | AC | 90 ms
3,516 KB |
testcase_75 | AC | 104 ms
3,516 KB |
testcase_76 | AC | 133 ms
3,420 KB |
testcase_77 | AC | 51 ms
3,412 KB |
testcase_78 | AC | 50 ms
3,400 KB |
testcase_79 | AC | 136 ms
3,416 KB |
testcase_80 | AC | 143 ms
3,500 KB |
testcase_81 | AC | 47 ms
3,404 KB |
testcase_82 | AC | 111 ms
3,564 KB |
testcase_83 | AC | 78 ms
3,452 KB |
testcase_84 | AC | 237 ms
3,548 KB |
testcase_85 | AC | 125 ms
3,416 KB |
testcase_86 | AC | 69 ms
3,408 KB |
testcase_87 | AC | 172 ms
3,420 KB |
testcase_88 | AC | 74 ms
3,516 KB |
testcase_89 | AC | 52 ms
3,508 KB |
testcase_90 | AC | 116 ms
3,484 KB |
testcase_91 | AC | 107 ms
3,424 KB |
testcase_92 | AC | 165 ms
3,412 KB |
testcase_93 | AC | 65 ms
3,404 KB |
testcase_94 | AC | 91 ms
3,564 KB |
testcase_95 | AC | 89 ms
3,412 KB |
testcase_96 | AC | 80 ms
3,412 KB |
testcase_97 | AC | 106 ms
3,416 KB |
testcase_98 | AC | 51 ms
3,484 KB |
testcase_99 | AC | 108 ms
3,412 KB |
ソースコード
#include <iostream> #include <list> #include <vector> #include <string> #include <stdio.h> #include <stdint.h> #include <iomanip> using namespace std; using uint = unsigned int; using ll = long long; #define CIN( LL , A ) LL A; cin >> A #define GETLINE( A ) string A; getline( cin , A ) #define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) #define FOR_LL( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR_LL( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define RETURN( ANSWER ) cout << ( ANSWER ) << endl; return 0 #define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << endl; return 0 #define MIN( A , B ) A < B ? A : B; #define MAX( A , B ) A < B ? B : A; template <typename T> inline T Distance( const T& a , const T& b ){ return a < b ? b - a : a - b; } #include <initializer_list> // 自分のライブラリ(https://github.com/p-adic/cpp)よりソースコードをコピーして編集している。 template <typename T , uint D> class AffineSpace { private: T m_v[D]; public: inline AffineSpace(); inline AffineSpace( const initializer_list<T> init ); template <uint E> inline AffineSpace( const T (&v)[E] ); template <uint E> inline AffineSpace( const AffineSpace<T,E>& x ); // E < Dの場合のみサポート template <typename... ARGS> inline AffineSpace( const uint& E , const ARGS&... args ); template <uint E> inline AffineSpace<T,D>& operator=( const AffineSpace<T,E>& x ); T& operator[]( const uint& i ); const T& operator[]( const uint& i ) const; private: template <uint E> void Set( const T (&v)[E] ); void Substitute( const initializer_list<T> init ); template <uint E> void Substitute( const T (&v)[E] ); template <uint E> void Substitute( const AffineSpace<T,E>& x ); }; template <typename T , uint D> inline AffineSpace<T,D>::AffineSpace() : m_v() {}; template <typename T , uint D> inline AffineSpace<T,D>::AffineSpace( const initializer_list<T> init ) : m_v() { Substitute( init ); } template <typename T , uint D> template <uint E> inline AffineSpace<T,D>::AffineSpace( const T (&v)[E] ) : m_v() { Substitute<E>( v ); } template <typename T , uint D> template <uint E> inline AffineSpace<T,D>::AffineSpace( const AffineSpace<T,E>& x ) : m_v() { Substitute<E>( x ); } template <typename T , uint D> template <typename... ARGS> inline AffineSpace<T,D>::AffineSpace( const uint& E , const ARGS&... args ) : AffineSpace( args... ) { m_v[E]++; } template <typename T , uint D> template <uint E> inline AffineSpace<T,D>& AffineSpace<T,D>::operator=( const AffineSpace<T,E>& x ) { Set<E>( x.m_v ); return *this; } template <typename T , uint D> inline T& AffineSpace<T,D>::operator[]( const uint& i ) { return m_v[i]; } template <typename T , uint D> inline const T& AffineSpace<T,D>::operator[]( const uint& i ) const { return m_v[i]; } template <typename T , uint D> template <uint E> void AffineSpace<T,D>::Set( const T (&v)[E] ) { Substitute( v ); constexpr const uint min = E < D ? E : D; for( uint i = min ; i < D ; i++ ){ m_v[i] = 0; } return; } template <typename T , uint D> void AffineSpace<T,D>::Substitute( const initializer_list<T> init ) { const uint size = init.size(); const uint min = size < D ? size : D; auto itr = init.begin(); for( uint i = 0 ; i < min ; i++ ){ m_v[i] = *itr; itr++; } return; } template <typename T , uint D> template <uint E> void AffineSpace<T,D>::Substitute( const T (&v)[E] ) { constexpr const uint min = E < D ? E : D; for( uint i = 0 ; i < min ; i++ ){ m_v[i] = v[i]; } return; } template <typename T , uint D> template <uint E> void AffineSpace<T,D>::Substitute( const AffineSpace<T,E>& x ) { constexpr const uint min = E < D ? E : D; for( uint i = 0 ; i < min ; i++ ){ m_v[i] = x[i]; } return; } #define N 2048 #define D 256 bool CheckSolution( const list<AffineSpace<ll,6> >& restriction , const AffineSpace<ll,D>& x ); int main() { AffineSpace<ll,D> x{}; list<AffineSpace<ll,6> > restriction{}; FOR_LL( i , 0 , N ){ CIN( uint , a ); CIN( uint , b ); CIN( uint , c ); CIN( ll , p ); CIN( ll , q ); CIN( ll , r ); restriction.push_back( AffineSpace<ll,6>( { a , b , c , p , q , r } ) ); bool solvable = CheckSolution( restriction , x ); if( ! solvable ){ FOR_LL( d , 0 , D ){ x[d] = 1 - x[d]; if( CheckSolution( restriction , x ) ){ solvable = true; d = D; } else { x[d] = 1 - x[d]; } } } if( ! solvable ){ FOR_LL( d0 , 0 , D ){ FOR_LL( d1 , 0 , D ){ x[d0] = 1 - x[d0]; x[d1] = 1 - x[d1]; if( CheckSolution( restriction , x ) ){ solvable = true; d0 = D; d1 = D; } else { x[d0] = 1 - x[d0]; x[d1] = 1 - x[d1]; } } } } if( ! solvable ){ if( i < 10 ){ FOR_LL( d0 , 0 , D ){ FOR_LL( d1 , 0 , D ){ FOR_LL( d2 , 0 , D ){ x[d0] = 1 - x[d0]; x[d1] = 1 - x[d1]; x[d2] = 1 - x[d2]; if( CheckSolution( restriction , x ) ){ solvable = true; d0 = D; d1 = D; d2 = D; } else { x[d0] = 1 - x[d0]; x[d1] = 1 - x[d1]; x[d2] = 1 - x[d2]; } } } } } } if( ! solvable ){ i = N; } } FOR_LL( d , 0 , D ){ cout << x[D - 1 - d]; } RETURN( "" ); } bool CheckSolution( const list<AffineSpace<ll,6> >& restriction , const AffineSpace<ll,D>& x ) { FOR_ITR( restriction , itr , end ){ const AffineSpace<ll,6>& r = *itr; bool b = false; FOR_LL( k , 0 , 3 ){ if( x[r[k]] == r[k+3] ){ b = true; k = 3; } } if( !b ){ return false; } } return true; }