QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#721707 | #1957. Friendship Graphs | rgnerdplayer | Compile Error | / | / | C++20 | 1.2kb | 2024-11-07 16:39:07 | 2024-11-07 16:39:07 |
Judging History
answer
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
int n, m;
cin >> n >> m;
vector adj(n, vector<int>(n));
while (m--) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u][v] = adj[v][u] = true;
}
vector<int> col(n, -1);
vector<int> dp(n + 1);
dp[0] = true;
for (int i = 0; i < n; i++) {
if (col[i] != -1) {
continue;
}
vector<int> q{i};
col[i] = 0;
for (int j = 0; j < int(q.size()); j++) {
int u = q[j];
for (int v = 0; v < n; v++) {
if (u == v || adj[u][v]) {
continue;
}
if (col[v] == -1) {
q.push_back(v);
col[v] = col[u] ^ 1;
} else if (col[u] == col[v]) {
cout << "-1\n";
return;
}
}
}
int c0 = count_if(q.begin(), q.end(), [&](auto u) { return col[u] == 0; });
int c1 = q.size() - c0;
vector<int> ndp(n + 1);
for (int i = n; i >= 0; i--) {
if (i >= c0) {
ndp[i] |= dp[i - c0];
}
if (i >= c1) {
ndp[i] |= dp[i - c1];
}
}
dp = move(ndp);
}
for (int i = n / 2; i >= 0; i--) {
if (dp[i]) {
cout << n - 2 * i << '\n';
return;
}
}
};
solve();
}
Details
answer.code: In function ‘int main()’: answer.code:2:9: error: ‘cin’ was not declared in this scope 2 | cin.tie(nullptr)->sync_with_stdio(false); | ^~~ answer.code: In lambda function: answer.code:8:17: error: ‘vector’ was not declared in this scope 8 | vector adj(n, vector<int>(n)); | ^~~~~~ answer.code:13:25: error: ‘adj’ was not declared in this scope 13 | adj[u][v] = adj[v][u] = true; | ^~~ answer.code:16:24: error: expected primary-expression before ‘int’ 16 | vector<int> col(n, -1); | ^~~ answer.code:17:24: error: expected primary-expression before ‘int’ 17 | vector<int> dp(n + 1); | ^~~ answer.code:18:17: error: ‘dp’ was not declared in this scope 18 | dp[0] = true; | ^~ answer.code:21:29: error: ‘col’ was not declared in this scope 21 | if (col[i] != -1) { | ^~~ answer.code:24:32: error: expected primary-expression before ‘int’ 24 | vector<int> q{i}; | ^~~ answer.code:25:25: error: ‘col’ was not declared in this scope 25 | col[i] = 0; | ^~~ answer.code:26:49: error: ‘q’ was not declared in this scope 26 | for (int j = 0; j < int(q.size()); j++) { | ^ answer.code:29:55: error: ‘adj’ was not declared in this scope 29 | if (u == v || adj[u][v]) { | ^~~ answer.code:36:49: error: ‘cout’ was not declared in this scope 36 | cout << "-1\n"; | ^~~~ answer.code:41:43: error: ‘q’ was not declared in this scope 41 | int c0 = count_if(q.begin(), q.end(), [&](auto u) { return col[u] == 0; }); | ^ answer.code:41:34: error: ‘count_if’ was not declared in this scope 41 | int c0 = count_if(q.begin(), q.end(), [&](auto u) { return col[u] == 0; }); | ^~~~~~~~ answer.code:43:32: error: expected primary-expression before ‘int’ 43 | vector<int> ndp(n + 1); | ^~~ answer.code:46:41: error: ‘ndp’ was not declared in this scope 46 | ndp[i] |= dp[i - c0]; | ^~~ answer.code:49:41: error: ‘ndp’ was not declared in this scope 49 | ndp[i] |= dp[i - c1]; | ^~~ answer.code:52:35: error: ‘ndp’ was not declared in this scope 52 | dp = move(ndp); | ^~~ answer.code:52:30: error: ‘move’ was not declared in this scope 52 | dp = move(ndp); | ^~~~ answer.code:57:33: error: ‘cout’ was not declared in this scope 57 | cout << n - 2 * i << '\n'; | ^~~~