QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#338223#5523. Graph Problem With Small $n$ucup-team1087Compile Error//C++171.5kb2024-02-25 19:21:162024-02-25 19:21:16

Judging History

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

  • [2024-02-25 19:21:16]
  • 评测
  • [2024-02-25 19:21:16]
  • 提交

answer

#include <iostream>
using namespace std;

template <class T>
T uread() {
    char c = getchar();
    while (c < '0' || c > '9') {
        c = getchar();
    }
    T num = 0;
    while (c >= '0' && c <= '9') {
        num = (num << 1) + (num << 3) + (c ^ 48);
        c = getchar();
    }
    return num;
}
template <class T>
T bread() {
    char c = getchar();
    while (c < '0' || c > '9') {
        c = getchar();
    }
    T num = 0; int len = 0;
    while (c >= '0' && c <= '9') {
        num |= (c ^ 48) * (1 << len++);
        c = getchar();
    }
    return num;
}

const int N = 24;

int reach[1 << N];

int main(int argc, const char * argv[]) {
    int n = uread<int>(), all = (1 << n) - 1, graph[N];
    for (int i = 0; i < n; ++i) {
        graph[i] = bread<int>();
    }
    reach[1] = 1;
    for (int state = 1; state <= all; state += 2) {
        int edge = 0;
        for (int i = reach[state]; i; i &= i - 1) {
            edge |= graph[__builtin_ctz(i)];
        }
        for (int i = edge & (all ^ state); i; i &= i - 1) {
            reach[state | (i & -i)] |= i & -i;
        }
    }
    int ans[N]; memset(ans, 0, sizeof(ans));
    for (int state = 1; state <= all; state += 2) {
        for (int i = reach[state]; i; i &= i - 1) {
            ans[__builtin_ctz(i)] |= reach[(all ^ state) | 1];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            putchar((ans[i] >> j & 1) + '0');
        }
        putchar('\n');
    }
    return 0;
}

详细

answer.code: In function ‘int main(int, const char**)’:
answer.code:50:17: error: ‘memset’ was not declared in this scope
   50 |     int ans[N]; memset(ans, 0, sizeof(ans));
      |                 ^~~~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;