QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691147#2943. NeighborsnickbelovCompile Error//C++201.9kb2024-10-31 10:07:562024-10-31 10:07:57

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 10:07:57]
  • 评测
  • [2024-10-31 10:07:56]
  • 提交

answer

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define F(i, k) for(int16_t i = 0; i < (k); ++i)
#define G(x) int16_t x; cin >> x;
#define D for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) cout << gr[i][j] << " \n"[j == m];
#define MT(r, c, i) (!i ? r : c)
#define N 15
#define M 2

int16_t n = -1, m = -1;
int16_t gr[N][N], mk[M][N];int8_t du[N][N], dl[N][N];
int16_t tbl[N][3];

#define ADD(r, c, x) { gr[r][c] ^= x; F(i, M) mk[i][MT(r, c, i)] ^= 1 << x; }

bool bT(int16_t r, int16_t c) {
    if(r > n) return true;
    int16_t rI = r + (c == m), cI = c % m + 1;
    if(gr[r][c]) return bT(rI, cI);
    int16_t mask = mk[0][r] & mk[1][c]
        & tbl[gr[r - 1][c]][du[r][c]] & tbl[gr[r][c - 1]][dl[r][c]]
        & tbl[gr[r + 1][c]][du[r + 1][c]] & tbl[gr[r][c + 1]][dl[r][c + 1]];
    for(int16_t x = __builtin_ctzll(mask); mask >> x; ++x) if((mask >> x) & 1) {
        ADD(r, c, x);
        if(bT(rI, cI)) return true;
        ADD(r, c, x);
    }
    return false;
}

void init() {
    cin >> n; G(k) m = n;
    fill_n(tbl[0], 3, (1 << 15) - 1);
    F(i, n + 1) if(i) {
        tbl[i][0] = (1 << 15) - 1; //no constraint
        tbl[i][2] = 5 << (i - 1); //diamond
        tbl[i][1] = ~tbl[i][2]; //no diamond
    }
    F(q, 2 * n - 1) if(q & 1) {
        int16_t r = (q + 1) / 2;
        string s; cin >> s;
        F(i, n) du[r + 1][i + 1] = 1 + (s[i] == '1');
    } else {
        int16_t r = q / 2;
        string s; cin >> s;
        F(i, n) if(i) dl[r + 1][i + 1] = 1 + (s[i - 1] == '1');
    }
    F(i, M) fill_n(mk[i], N, (1 << (n + 1)) - 2);
    while(k--) {
        G(r) G(c) G(v)
        ADD(r, c, v);
    }
}

int main() {
    clock_t t = clock();
    init(); bT(1, 1); D
    cout << (clock() - t) / (double)(CLOCKS_PER_SEC) << '\n';
} 

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~