結果
| 問題 |
No.5005 3-SAT
|
| ユーザー |
trineutron
|
| 提出日時 | 2022-03-29 02:29:30 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,918 ms / 2,000 ms |
| コード長 | 2,612 bytes |
| コンパイル時間 | 764 ms |
| 実行使用メモリ | 6,948 KB |
| スコア | 48,643 |
| 最終ジャッジ日時 | 2022-04-29 13:48:22 |
| 合計ジャッジ時間 | 198,499 ms |
|
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
#include <bitset>
#include <cassert>
#include <iostream>
#include <random>
using namespace std;
class xrand {
uint64_t x;
public:
using result_type = uint32_t;
static constexpr result_type min() {
return numeric_limits<result_type>::min();
}
static constexpr result_type max() {
return numeric_limits<result_type>::max();
}
xrand(uint64_t k) : x(k) {}
xrand() : xrand(1) {}
result_type operator()() {
x ^= x << 9;
x ^= x >> 7;
return (x * 0x123456789abcdef) >> 32;
}
};
constexpr int n = 256, len = 2048;
uint32_t a[len], b[len], c[len], a1[len], b1[len], c1[len];
xrand rng;
int calc_score(const bitset<n> &s) {
for (int i = 0; i < len; i++) {
if (s[a[i]] != a1[i] and s[b[i]] != b1[i] and s[c[i]] != c1[i]) {
return i;
}
}
return len;
}
int main() {
const clock_t start = clock();
for (int i = 0; i < len; i++) {
cin >> a[i] >> b[i] >> c[i] >> a1[i] >> b1[i] >> c1[i];
}
bitset<n> best, s;
int best_score = calc_score(best), count = 0;
while (true) {
const double phase = (clock() - start) / (1.9 * CLOCKS_PER_SEC);
if (phase >= 1) break;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < n / 32; j++) {
s <<= 32;
s |= rng();
}
bitset<n> locked;
int score = 0;
for (int j = 0; j < len; j++) {
if (s[a[j]] == a1[j] and locked[a[j]]) continue;
if (s[b[j]] == b1[j] and locked[b[j]]) continue;
if (s[c[j]] == c1[j] and locked[c[j]]) continue;
if (s[a[j]] == a1[j]) {
locked.set(a[j]);
} else if (s[b[j]] == b1[j]) {
locked.set(b[j]);
} else if (s[c[j]] == c1[j]) {
locked.set(c[j]);
} else if (not locked[a[j]]) {
s.flip(a[j]);
locked.set(a[j]);
} else if (not locked[b[j]]) {
s.flip(b[j]);
locked.set(b[j]);
} else if (not locked[c[j]]) {
s.flip(c[j]);
locked.set(c[j]);
} else {
score = j;
break;
}
}
if (score > best_score) {
best_score = score;
best = s;
}
count++;
}
}
cout << best << endl;
cerr << count << endl;
return 0;
}
trineutron