# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
780647 |
2023-07-12T11:22:24 Z |
vjudge1 |
Simurgh (IOI17_simurgh) |
C++17 |
|
86 ms |
4052 KB |
#include <bits/stdc++.h>
#include "simurgh.h"
#define all(x) (x).begin(),(x).end()
using namespace std;
//#define ask count_common_roads
using ll = long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
const int nmax = 500;
vector<pii> g[nmax];
vector<int> occ;
vector<int> candr;
int flag;
int cnt = 0;
int ask(vector<int> r) {
return count_common_roads(r);
}
void dfs(int x) {
occ[x] = flag;
for(auto [y, ptr] : g[x]) {
if(occ[y] != 0) continue;
//cerr << x << ' ' << y << '\t' << ptr << '\n';
occ[y] = flag;
candr.emplace_back(ptr);
dfs(y);
}
return;
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
occ.resize(n);
vector<int> isgood(sz(u), 0);
vector<int> checked(sz(u), 0);
for(int i = 0; i < sz(u); i++) {
g[u[i]].emplace_back(v[i], i);
g[v[i]].emplace_back(u[i], i);
}
for(int i = 0; i < n; i++) {
fill(all(occ), 0);
candr.clear();
occ[i] = -1;
vector<vector<int>> atrs;
atrs.emplace_back();
vector<int> nv;
flag = 0;
for(auto [x, ptr] : g[i]) {
if(occ[x] == 0) {
flag++;
dfs(x);
nv.emplace_back(ptr);
atrs.emplace_back();
atrs.back().emplace_back(ptr);
}
else
atrs[occ[x]].emplace_back(ptr);
}
//cerr << i <<'\n';
//for(auto x : candr) cerr << x << ' ';
//cerr << '\n';
//for(auto x : nv) cerr << x << ' ';
//cerr << '\n';
int startmn = sz(candr) - 1;
copy(all(nv), back_inserter(candr));
for(int i = 1; i <= flag; i++) {
//cerr << "--\n";
vector<int> rez;
int mx = -1;
for(int j = 0; j < sz(atrs[i]); j++) {
int u = atrs[i][j];
candr[startmn + i] = u;
if(checked[u] && isgood[u]) { mx = ask(candr); break; }
}
for(int j = 0; j < sz(atrs[i]); j++) {
int u = atrs[i][j];
candr[startmn + i] = u;
if(!checked[u])
rez.emplace_back(ask(candr));
else
rez.emplace_back(-1);
}
if(mx == -1)
mx = *max_element(all(rez));
for(int j = 0; j < sz(atrs[i]); j++) {
checked[atrs[i][j]] = 1;
if(rez[j] == mx)
isgood[atrs[i][j]] = 1;
}
//cerr << "--\n";
}
//cerr << "=======\n";
}
vector<int> lst;
for(int i = 0; i < sz(isgood); i++)
if(isgood[i])
lst.emplace_back(i);
//for(auto x : lst)
//cerr << x << ' ';
//cerr << '\n';
return lst;
}
/**
Anul asta se da centroid.
-- Surse oficiale
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
1 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
1 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
220 KB |
correct |
19 |
Correct |
1 ms |
340 KB |
correct |
20 |
Correct |
1 ms |
340 KB |
correct |
21 |
Correct |
1 ms |
340 KB |
correct |
22 |
Correct |
1 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
1 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
1 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
1 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
1 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
220 KB |
correct |
19 |
Correct |
1 ms |
340 KB |
correct |
20 |
Correct |
1 ms |
340 KB |
correct |
21 |
Correct |
1 ms |
340 KB |
correct |
22 |
Correct |
1 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
1 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
1 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
34 |
Correct |
78 ms |
1556 KB |
correct |
35 |
Correct |
75 ms |
1548 KB |
correct |
36 |
Correct |
53 ms |
1236 KB |
correct |
37 |
Correct |
6 ms |
340 KB |
correct |
38 |
Correct |
86 ms |
1544 KB |
correct |
39 |
Correct |
67 ms |
1364 KB |
correct |
40 |
Correct |
53 ms |
1324 KB |
correct |
41 |
Correct |
85 ms |
1564 KB |
correct |
42 |
Correct |
81 ms |
1612 KB |
correct |
43 |
Correct |
44 ms |
1108 KB |
correct |
44 |
Correct |
36 ms |
852 KB |
correct |
45 |
Correct |
40 ms |
932 KB |
correct |
46 |
Correct |
31 ms |
724 KB |
correct |
47 |
Correct |
15 ms |
468 KB |
correct |
48 |
Correct |
3 ms |
340 KB |
correct |
49 |
Correct |
5 ms |
396 KB |
correct |
50 |
Correct |
15 ms |
468 KB |
correct |
51 |
Correct |
41 ms |
852 KB |
correct |
52 |
Correct |
46 ms |
872 KB |
correct |
53 |
Correct |
31 ms |
724 KB |
correct |
54 |
Correct |
43 ms |
1108 KB |
correct |
55 |
Correct |
40 ms |
932 KB |
correct |
56 |
Correct |
48 ms |
852 KB |
correct |
57 |
Correct |
47 ms |
852 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Incorrect |
59 ms |
4052 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
1 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Correct |
1 ms |
340 KB |
correct |
15 |
Correct |
1 ms |
340 KB |
correct |
16 |
Correct |
1 ms |
340 KB |
correct |
17 |
Correct |
1 ms |
340 KB |
correct |
18 |
Correct |
1 ms |
220 KB |
correct |
19 |
Correct |
1 ms |
340 KB |
correct |
20 |
Correct |
1 ms |
340 KB |
correct |
21 |
Correct |
1 ms |
340 KB |
correct |
22 |
Correct |
1 ms |
340 KB |
correct |
23 |
Correct |
1 ms |
340 KB |
correct |
24 |
Correct |
1 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
212 KB |
correct |
26 |
Correct |
1 ms |
340 KB |
correct |
27 |
Correct |
1 ms |
340 KB |
correct |
28 |
Correct |
1 ms |
212 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
1 ms |
340 KB |
correct |
31 |
Correct |
2 ms |
340 KB |
correct |
32 |
Correct |
1 ms |
340 KB |
correct |
33 |
Correct |
2 ms |
340 KB |
correct |
34 |
Correct |
78 ms |
1556 KB |
correct |
35 |
Correct |
75 ms |
1548 KB |
correct |
36 |
Correct |
53 ms |
1236 KB |
correct |
37 |
Correct |
6 ms |
340 KB |
correct |
38 |
Correct |
86 ms |
1544 KB |
correct |
39 |
Correct |
67 ms |
1364 KB |
correct |
40 |
Correct |
53 ms |
1324 KB |
correct |
41 |
Correct |
85 ms |
1564 KB |
correct |
42 |
Correct |
81 ms |
1612 KB |
correct |
43 |
Correct |
44 ms |
1108 KB |
correct |
44 |
Correct |
36 ms |
852 KB |
correct |
45 |
Correct |
40 ms |
932 KB |
correct |
46 |
Correct |
31 ms |
724 KB |
correct |
47 |
Correct |
15 ms |
468 KB |
correct |
48 |
Correct |
3 ms |
340 KB |
correct |
49 |
Correct |
5 ms |
396 KB |
correct |
50 |
Correct |
15 ms |
468 KB |
correct |
51 |
Correct |
41 ms |
852 KB |
correct |
52 |
Correct |
46 ms |
872 KB |
correct |
53 |
Correct |
31 ms |
724 KB |
correct |
54 |
Correct |
43 ms |
1108 KB |
correct |
55 |
Correct |
40 ms |
932 KB |
correct |
56 |
Correct |
48 ms |
852 KB |
correct |
57 |
Correct |
47 ms |
852 KB |
correct |
58 |
Correct |
1 ms |
212 KB |
correct |
59 |
Correct |
1 ms |
212 KB |
correct |
60 |
Incorrect |
59 ms |
4052 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |