QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134434 | #2760. Simurgh | Qwerty1232# | 13 | 262ms | 4100kb | C++20 | 1.8kb | 2023-08-03 19:36:23 | 2024-07-04 01:15:56 |
Judging History
answer
#include "simurgh.h"
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <random>
struct DSU {
std::vector<int> prv;
DSU(int n) {
clear(n);
}
void clear(int n) {
prv.assign(n, -1);
}
int get(int i) {
return prv[i] == -1 ? i : prv[i] = get(prv[i]);
}
void merge(int u, int v) {
u = get(u);
v = get(v);
assert(u != v);
prv[u] = v;
}
};
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
static std::mt19937 rnd;
int m = u.size();
std::vector<std::pair<int, int>> edg(m);
for (int i = 0; i < m; i++) {
edg[i] = {u[i], v[i]};
}
std::vector<int> all(m);
std::iota(all.begin(), all.end(), 0);
std::shuffle(all.begin(), all.end(), rnd);
std::vector<int> ans;
DSU dsu(n);
for (int i : all) {
auto [u, v] = edg[i];
if (dsu.get(u) != dsu.get(v)) {
dsu.merge(u, v);
ans.push_back(i);
}
}
int cnt_rl = count_common_roads(ans);
while (cnt_rl != n - 1) {
std::shuffle(all.begin(), all.end(), rnd);
auto ans2 = ans;
std::shuffle(ans2.begin(), ans2.end(), rnd);
ans2.pop_back();
dsu.clear(n);
for (int i : ans2) {
auto [u, v] = edg[i];
dsu.merge(u, v);
}
for (int i : all) {
auto [u, v] = edg[i];
if (dsu.get(u) != dsu.get(v)) {
dsu.merge(u, v);
ans2.push_back(i);
}
}
int cnt_rl2 = count_common_roads(ans2);
if (cnt_rl2 > cnt_rl) {
ans = ans2;
cnt_rl = cnt_rl2;
}
}
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 13
Accepted
Test #1:
score: 13
Accepted
time: 1ms
memory: 3812kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 21 30000 2 0 0 1 5 2 2 6 1 3 3 0 6 0 4 5 3 2 4 0 1 4 0 5 4 3 4 6 6 1 2 1 5 3 2 4 5 6 5 1 6 3 7 10 9 13 12 17
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 9 12 10 7 17 13
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3796kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 21 30000 4 6 1 6 2 3 0 3 2 1 2 6 5 6 6 3 0 2 1 0 4 2 1 3 5 2 5 0 0 6 5 3 4 5 5 1 3 4 1 4 4 0 4 16 10 0 20 18
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 10 16 20 18 4 0
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 21 30000 2 5 0 4 4 5 4 3 5 3 1 3 3 6 4 1 6 0 5 6 6 2 6 1 6 4 3 2 2 1 1 0 0 2 5 0 5 1 4 2 0 3 20 17 15 9 2 19
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 17 19 9 15 20 2
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 13 30000 2 4 4 3 3 2 0 3 0 4 6 3 6 1 4 5 6 2 1 3 5 6 6 0 6 4 3 9 12 7 0 4
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 4 9 0 3 7 12
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 4072kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 6 10 30000 5 2 0 1 1 2 0 3 3 2 1 4 0 5 3 5 4 3 1 3 5 0 7 2 1
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 0 2 5 1 7
result:
ok correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 16 30000 3 4 2 5 2 1 0 5 1 5 0 2 2 6 6 1 4 6 0 1 2 3 6 3 3 1 1 4 4 5 3 5 0 9 5 15 3 11
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 15 0 11 3 9 5
result:
ok correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 2 1 30000 0 1 0
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 0
result:
ok correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 3 3 30000 0 1 2 0 1 2 2 0
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 0 2
result:
ok correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 6 5 30000 2 4 5 4 4 0 4 1 3 4 3 1 4 0 2
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 3 2 4 0 1
result:
ok correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 4100kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 6 14 30000 4 2 1 3 4 5 4 1 0 4 0 1 2 3 2 1 0 3 5 3 0 5 0 2 5 2 1 5 13 8 10 7 3
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 8 13 3 10 7
result:
ok correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 4064kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 6 30000 3 0 3 5 4 0 5 6 0 2 1 3 3 4 1 5 0 2
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 2 3 0 5 4 1
result:
ok correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 6 15 30000 4 3 2 3 3 5 2 0 5 2 1 3 1 4 0 5 3 0 4 0 1 0 2 1 4 5 4 2 5 1 9 13 12 6 0
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 12 6 0 9 13
result:
ok correct
Test #13:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 7 21 30000 0 2 2 5 3 4 0 3 5 4 4 2 2 1 4 6 5 3 0 1 4 0 1 6 3 6 1 3 1 5 5 0 0 6 4 1 6 5 3 2 2 6 16 3 18 17 4 6
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 3 16 4 6 18 17
result:
ok correct
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #14:
score: 0
Wrong Answer
time: 262ms
memory: 3840kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 50 1225 30000 47 4 24 48 42 13 5 42 19 17 29 31 23 48 37 25 37 43 27 22 43 30 19 44 49 37 39 14 26 46 46 35 49 15 40 19 6 31 37 1 21 0 26 45 6 4 38 36 6 8 20 4 18 24 20 35 5 29 1 19 35 49 29 20 25 10 10 36 2 22 26 11 7 9 24 3 35 38 48 41 22...
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs WA NO
result:
wrong answer WA in grader: NO
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #58:
score: 19
Accepted
time: 0ms
memory: 3816kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 2 1 12000 1 0 0
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 0
result:
ok correct
Test #59:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 10 45 12000 4 8 0 5 2 0 5 8 8 0 3 8 6 4 4 1 2 3 2 1 6 2 1 7 3 7 8 1 7 0 8 6 0 6 9 5 9 6 7 4 7 6 7 9 1 6 3 5 2 5 7 5 3 9 0 3 3 6 2 9 1 5 0 4 7 8 5 4 9 4 5 6 3 1 2 8 7 2 2 4 1 0 9 8 4 3 1 9 9 0 22 41 3 16 7 25 28 11 39
output:
lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs OK 41 3 11 7 28 16 39 22 25
result:
ok correct
Test #60:
score: -19
Time Limit Exceeded
input:
wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd 400 79800 12000 32 64 96 254 115 203 7 171 112 81 124 143 336 175 217 328 152 133 124 331 19 91 92 232 152 43 215 169 4 341 363 18 83 99 52 46 248 66 242 187 150 319 335 158 172 150 3 49 126 256 60 153 165 230 265 68 119 380 171 22 35 169 3...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%