QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#294633 | #4829. Mark on a Graph | ucup-team1525# | 0 | 1ms | 3772kb | C++20 | 1.6kb | 2023-12-30 15:10:47 | 2023-12-30 15:10:47 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1050;
const int LAMBDA = 8000;
int n, m;
vector<int> e[N];
int f[N];
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
bool is_con(int u, int v) {
int fu = Find(u), fv = Find(v);
return fu == fv;
}
void connect(int u, int v) {
int fu = Find(u), fv = Find(v);
if (fu != fv)
f[fv] = fu;
}
using pii = pair<int, int>;
void work_mark() {
for (int i = 1; i <= n; i++)
f[i] = i;
for (int i = 1; i <= n; i++)
for (auto v : e[i])
connect(i, v);
sort(e + 1, e + n + 1, [](auto x, auto y) {
return x.size() < y.size();
});
int cnt = 5;
vector<pii> vec;
for (int i = 1; i <= n; i++) {
for (auto v : e[i]) {
cnt--;
vec.push_back({i, v});
if (cnt == 0)
break;
}
if (cnt == 0)
break;
}
cout << "mark\n";
cout << vec.size() << "\n";
for (auto [u, v] : vec) {
cout << u << " " << v << "\n";
}
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
int u, v;
scanf("%d%d", &u, &v);
e[u].push_back(v);
e[v].push_back(u);
}
int isolate = 0;
for (int i = 1; i <= n; i++) {
if (e[i].size() == 0)
isolate++;
}
// cerr << "isolate: " << isolate << endl;
if (isolate * m > LAMBDA) {
cout << "ok" << endl;
return 0;
}
work_mark();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
1000 3560 603 151 415 20 102 569 895 552 678 734 24 614 689 518 440 223 751 919 223 433 711 551 502 634 706 583 812 501 514 535 780 751 720 530 532 384 888 139 864 791 292 675 171 881 30 592 464 557 280 299 654 650 894 335 250 532 792 10 83 969 118 771 579 300 852 983 243 940 957 939 817 889 911 319...
output:
mark 5 2 817 3 826 4 386 5 812 6 353
input:
1000 3565 626 643 295 222 429 542 534 33 682 582 107 833 746 181 656 841 184 217 383 221 676 187 815 771 397 161 759 167 640 763 707 250 342 897 224 873 974 302 521 228 368 12 676 977 113 210 639 831 715 526 95 125 440 102 70 757 464 840 87 733 355 335 232 687 178 201 182 394 201 34 617 583 221 937 ...
output:
mark 5 2 104 3 839 4 330 5 856 6 269
result:
wrong answer Token "mark" doesn't correspond to pattern "ok"