QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#338223 | #5523. Graph Problem With Small $n$ | ucup-team1087 | Compile Error | / | / | C++17 | 1.5kb | 2024-02-25 19:21:16 | 2024-02-25 19:21:16 |
Judging History
This is the latest submission verdict.
- [2024-02-25 19:21:16]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-02-25 19:21:16]
- Submitted
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;
}
Details
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;