結果
問題 | No.5005 3-SAT |
ユーザー | siman |
提出日時 | 2022-05-05 19:24:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,103 bytes |
コンパイル時間 | 1,213 ms |
スコア | 0 |
最終ジャッジ日時 | 2022-05-05 19:27:52 |
合計ジャッジ時間 | 220,033 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | TLE | - |
testcase_43 | TLE | - |
testcase_44 | TLE | - |
testcase_45 | TLE | - |
testcase_46 | TLE | - |
testcase_47 | TLE | - |
testcase_48 | TLE | - |
testcase_49 | TLE | - |
testcase_50 | TLE | - |
testcase_51 | TLE | - |
testcase_52 | TLE | - |
testcase_53 | TLE | - |
testcase_54 | TLE | - |
testcase_55 | TLE | - |
testcase_56 | TLE | - |
testcase_57 | TLE | - |
testcase_58 | TLE | - |
testcase_59 | TLE | - |
testcase_60 | TLE | - |
testcase_61 | TLE | - |
testcase_62 | TLE | - |
testcase_63 | TLE | - |
testcase_64 | TLE | - |
testcase_65 | TLE | - |
testcase_66 | TLE | - |
testcase_67 | TLE | - |
testcase_68 | TLE | - |
testcase_69 | TLE | - |
testcase_70 | TLE | - |
testcase_71 | TLE | - |
testcase_72 | TLE | - |
testcase_73 | TLE | - |
testcase_74 | TLE | - |
testcase_75 | TLE | - |
testcase_76 | TLE | - |
testcase_77 | TLE | - |
testcase_78 | TLE | - |
testcase_79 | TLE | - |
testcase_80 | TLE | - |
testcase_81 | TLE | - |
testcase_82 | TLE | - |
testcase_83 | TLE | - |
testcase_84 | TLE | - |
testcase_85 | TLE | - |
testcase_86 | TLE | - |
testcase_87 | TLE | - |
testcase_88 | TLE | - |
testcase_89 | TLE | - |
testcase_90 | TLE | - |
testcase_91 | TLE | - |
testcase_92 | TLE | - |
testcase_93 | TLE | - |
testcase_94 | TLE | - |
testcase_95 | TLE | - |
testcase_96 | TLE | - |
testcase_97 | TLE | - |
testcase_98 | TLE | - |
testcase_99 | TLE | - |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; ll g_start_cycle; const ll CYCLE_PER_SEC = 2700000000; double TIME_LIMIT = 1.8; unsigned long long int get_cycle() { unsigned int low, high; __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); return ((unsigned long long int) low) | ((unsigned long long int) high << 32); } double get_time(unsigned long long int begin_cycle) { return (double) (get_cycle() - begin_cycle) / CYCLE_PER_SEC; } unsigned long long xor128() { static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123; unsigned long long rt = (rx ^ (rx << 11)); rx = ry; ry = rz; rz = rw; return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8))); } const int QUERY_NUM = 2048; const int L = 256; const int BIT_PTN[8][3] = { {0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}, }; struct Query { int a; int b; int c; int p; int q; int r; Query(int a = -1, int b = -1, int c = -1, int p = -1, int q = -1, int r = -1) { this->a = a; this->b = b; this->c = c; this->p = p; this->q = q; this->r = r; } }; vector <Query> g_query_list; vector<int> g_ids[QUERY_NUM]; int g_bit_ptn[L]; class SAT { public: void init() { g_start_cycle = get_cycle(); setup(); } void setup() { vector<int> G[L]; for (int i = 0; i < QUERY_NUM; ++i) { Query &query = g_query_list[i]; G[query.a].push_back(i); G[query.b].push_back(i); G[query.c].push_back(i); } for (int i = 0; i < QUERY_NUM; ++i) { Query &query = g_query_list[i]; set<int> ids; for (int id : G[query.a]) { ids.insert(id); } for (int id : G[query.b]) { ids.insert(id); } for (int id : G[query.c]) { ids.insert(id); } for (int id : ids) { g_ids[i].push_back(id); } } } string run() { string res = ""; init(); search_best_bit_ptn(); return res; } vector<int> search_best_bit_ptn() { memset(g_bit_ptn, 0, sizeof(g_bit_ptn)); vector<int> res(L, 0); double cur_time = get_time(g_start_cycle); int try_count = 0; while (cur_time < TIME_LIMIT) { cur_time = get_time(g_start_cycle); int qid = xor128() % QUERY_NUM; search_best_ptn(qid); ++try_count; } int score = calc_score_full(); fprintf(stderr, "try_count: %d, best_score: %d\n", try_count, score); return res; } int calc_score_full() { int score = 0; for (int qid = 0; qid < QUERY_NUM; ++qid) { Query &query = g_query_list[qid]; if (g_bit_ptn[query.a] == query.p && g_bit_ptn[query.b] == query.q && g_bit_ptn[query.c] == query.r) { ++score; } } return score; } void search_best_ptn(int qid) { Query &q = g_query_list[qid]; int best_score = 0; int best_ptn_id = 0; for (int pid = 0; pid < 8; ++pid) { g_bit_ptn[q.a] = BIT_PTN[pid][0]; g_bit_ptn[q.b] = BIT_PTN[pid][1]; g_bit_ptn[q.c] = BIT_PTN[pid][2]; int score = 0; for (int id : g_ids[qid]) { Query &query = g_query_list[id]; if (g_bit_ptn[query.a] == query.p && g_bit_ptn[query.b] == query.q && g_bit_ptn[query.c] == query.r) { ++score; } } if (best_score < score) { best_score = score; best_ptn_id = pid; } } g_bit_ptn[q.a] = BIT_PTN[best_ptn_id][0]; g_bit_ptn[q.b] = BIT_PTN[best_ptn_id][1]; g_bit_ptn[q.c] = BIT_PTN[best_ptn_id][2]; } }; int main() { int a, b, c, p, q, r; for (int i = 0; i < QUERY_NUM; ++i) { cin >> a >> b >> c >> p >> q >> r; g_query_list.push_back(Query(a, b, c, p, q, r)); } SAT sat; sat.run(); string res = ""; for (int i = 0; i < L; ++i) { res += to_string(g_bit_ptn[i]); } cout << res << endl; return 0; }