QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#159786 | #7107. Chaleur | ucup-team296# | AC ✓ | 171ms | 8008kb | C++20 | 3.0kb | 2023-09-02 18:41:33 | 2023-09-02 18:41:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../debug.h"
#else
#define dbg(...) 787788
#endif
void solve() {
int tc;
cin >> tc;
for (int t = 0; t < tc; t++) {
int n, m;
cin >> n >> m;
vector<vector<int>> g(n);
for (int i = 0; i < m; i++) {
int fr, to;
cin >> fr >> to;
fr -= 1;
to -= 1;
g[fr].push_back(to);
g[to].push_back(fr);
}
vector<int> perm;
for (int i = 0; i < n; i++) {
perm.push_back(i);
}
sort(perm.begin(), perm.end(), [&](int a, int b) {
return g[a].size() < g[b].size();
});
vector<bool> in_cliq(n, false);
int cliq = 0;
for (int pos = n - 1; pos >= 0; pos--) {
int v = perm[pos];
int cnt = 0;
for (int to : g[v]) {
if (in_cliq[to]) {
cnt++;
}
}
if (cnt == cliq) {
in_cliq[v] = true;
cliq++;
} else {
break;
}
}
for (int v = 0; v < n; v++) {
if (!in_cliq[v]) {
for (int to : g[v]) {
assert(in_cliq[to]);
}
}
}
int full_cliq = 0;
int almost_cliq = 0;
for (int v = 0; v < n; v++) {
if (!in_cliq[v]) {
int cnt_in_cliq = 0;
for (int to : g[v]) {
if (in_cliq[to]) {
cnt_in_cliq++;
}
}
if (cnt_in_cliq == cliq) {
full_cliq += 1;
} else {
if (cnt_in_cliq == cliq - 1) {
almost_cliq += 1;
}
}
}
}
int cliq_res = full_cliq == 0 ? (almost_cliq + 1) : full_cliq;
int full_not_cliq = 0;
int almost_not_cliq = 0;
for (int v = 0; v < n; v++) {
if (in_cliq[v]) {
int cnt_not_in_cliq = 0;
for (int to : g[v]) {
if (!in_cliq[to]) {
cnt_not_in_cliq++;
}
}
if (cnt_not_in_cliq == 0) {
full_not_cliq += 1;
} else if (cnt_not_in_cliq == 1) {
almost_not_cliq += 1;
}
}
}
int not_cliq_res = full_not_cliq == 0 ? (almost_not_cliq + 1) : full_not_cliq;
cout << cliq_res << " " << not_cliq_res << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
#include <filesystem>
run_all_tests(solve);
// run_single_test(solve, 1);
// solve();
#else
solve();
#endif
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
3 3 2 1 2 2 3 6 6 1 2 2 3 1 3 1 4 2 5 3 6 4 1 1 2
output:
2 1 1 4 1 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 171ms
memory: 8008kb
input:
2231 1 0 5 7 4 1 3 4 3 1 3 5 4 2 3 2 4 5 5 4 2 1 2 5 2 4 2 3 5 10 3 2 2 5 1 4 4 2 4 5 1 2 1 3 3 5 3 4 1 5 5 10 1 3 2 4 1 4 5 2 2 3 1 5 5 4 1 2 3 4 5 3 5 9 2 5 3 5 2 3 2 1 4 3 3 1 4 1 4 5 2 4 5 4 4 2 4 1 4 5 4 3 5 9 4 1 4 5 3 4 2 4 2 1 3 1 2 5 3 5 3 2 5 4 2 5 2 3 2 1 2 4 5 9 5 2 1 3 4 3 1 2 5 4 4 2 5...
output:
1 1 3 1 4 1 1 5 1 5 2 1 4 1 2 1 4 1 2 1 2 1 3 1 4 1 4 1 1 5 2 1 4 1 1 5 1 5 1 5 3 1 4 1 4 1 4 1 3 1 3 1 4 1 4 1 2 1 4 1 4 1 1 5 1 5 2 1 4 1 4 1 4 1 3 1 2 1 4 1 2 1 4 1 4 1 4 1 3 1 1 5 4 1 4 1 1 5 2 1 4 1 2 1 2 1 1 5 4 1 1 5 3 1 4 1 1 5 2 1 1 5 3 1 3 1 1 5 3 1 3 1 2 1 1 5 4 1 3 1 1 5 2 1 3 1 2 1 2 1 ...
result:
ok 2231 lines
Extra Test:
score: 0
Extra Test Passed