QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325340 | #4829. Mark on a Graph | UNos_maricones# | 0 | 19ms | 7936kb | C++20 | 1.9kb | 2024-02-11 08:23:35 | 2024-02-11 08:23:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> pii;
const int N = 3e5+5;
const int oo = 1e9 - 1;
const int len = oo / 75;
mt19937_64 rng(1);
uniform_int_distribution<int> dis(0, 1000);
int g[1010][1010];
vector <pii> edges;
int deg[1010];
bool cmp (int u, int v) {
return deg[u] < deg[v];
}
int main(){
#ifdef LOCAL
freopen("input.txt","r",stdin);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m; cin >> n >> m;
for (int i = 0; i < m; ++i) {
int u, v; cin >> u >> v;
u--;v--;
deg[u]++;
deg[v]++;
edges.pb({u, v});
g[u][v] = g[v][u] = 1;
}
int has = 0;
for (auto &e1 : edges) {
for (auto &e2 : edges) {
int u = e1.ff, v = e1.ss, w = e2.ff, x = e2.ss;
if (u == v || u == w || u == x || v == w || v == x || w == x) continue;
if (!g[u][w] || !g[u][x] || !g[v][w] || !g[v][x]) continue;
vector <int> dgs = {deg[u], deg[v], deg[w], deg[x]};
sort (dgs.begin(), dgs.end());
if (dgs[2] > 6) continue;
has = 1;
}
}
if (has) cout << "ok\n";
else {
cout << "mark\n";
vector <int> ids;
for (int i = 0; i < n; ++i) ids.pb(i);
sort (ids.begin(), ids.end(), cmp);
vector <pii> to_mark;
int ond = ids[3];
for (int i = 3; i < n; ++i) {
if (g[ids[i]][ids[2]]) ond = ids[i];
}
vector <int> nds = {ids[0], ids[1], ids[2], ond};
for (auto &e : nds) {
for (auto &e2 : nds) {
if (e == e2) continue;
if (!g[e][e2]) {
to_mark.pb({e, e2});
g[e][e2] = g[e2][e] = 1;
}
}
}
assert(to_mark.size() <= 5);
cout << to_mark.size() << '\n';
for (auto &e : to_mark) cout << e.ff + 1 << ' ' << e.ss + 1 << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 7936kb
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 880 762 880 862 880 826 762 862 762 826
input:
1000 3565 626 107 295 222 665 811 534 909 682 496 706 833 155 199 656 841 184 286 383 294 86 259 532 771 37 355 755 167 484 763 209 250 693 401 224 873 974 302 521 380 363 479 676 977 920 112 175 831 805 688 692 125 654 102 70 757 464 840 87 733 956 373 600 137 178 201 182 394 201 34 975 583 557 937...
output:
ok
result:
ok all right
Test #2:
score: 0
Stage 1: Program answer Runtime Error
input:
1000 2000 457 335 160 497 464 992 892 255 853 3 308 301 970 363 541 299 89 418 425 128 626 827 603 854 484 874 755 295 607 483 798 552 356 850 320 357 254 940 675 901 168 525 301 636 520 555 773 910 343 701 889 966 218 529 909 950 71 64 682 284 424 138 721 792 670 544 386 72 654 909 725 235 592 437 ...