#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x,y) ((x+y-1)/(y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; --i)
#define trav(i,a) for(auto &i : a)
template<typename T>
void amin(T &a, T b) {
a = min(a,b);
}
template<typename T>
void amax(T &a, T b) {
a = max(a,b);
}
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
/*
read the edi a long time ago, dont really remember much from there
*/
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;
#include "incursion.h"
std::vector<int> mark(std::vector<std::pair<int, int>> F, int safe) {
// return {2, 2, 0};
int n = sz(F)+1;
vector<vector<int>> adj(n+5);
for(auto [u,v] : F){
adj[u].pb(v), adj[v].pb(u);
}
int r = -1;
rep1(i,n){
if(sz(adj[i]) == 2){
r = i;
}
}
assert(r != -1);
vector<int> par(n+5), subsiz(n+5);
auto dfs = [&](int u, int p, auto &&dfs) -> void{
par[u] = p;
subsiz[u] = 1;
trav(v,adj[u]){
if(v == p) conts;
dfs(v,u,dfs);
subsiz[u] += subsiz[v];
}
};
dfs(r,-1,dfs);
vector<int> centroids;
rep1(u,n){
bool ok = true;
trav(v,adj[u]){
int s = subsiz[v];
if(v == par[u]){
s = n-subsiz[u];
}
if(s > n/2){
ok = false;
}
}
if(ok){
centroids.pb(u);
}
}
int siz = sz(centroids);
assert(siz >= 1 and siz <= 2);
vector<int> ans(n);
while(safe != -1){
ans[safe-1] = 1;
safe = par[safe];
}
return ans;
}
void locate(std::vector<std::pair<int, int>> F, int curr, int cnt) {
int n = sz(F)+1;
vector<vector<int>> adj(n+5);
for(auto [u,v] : F){
adj[u].pb(v), adj[v].pb(u);
}
int r = -1;
rep1(i,n){
if(sz(adj[i]) == 2){
r = i;
}
}
assert(r != -1);
vector<int> par(n+5), subsiz(n+5);
auto dfs = [&](int u, int p, auto &&dfs) -> void{
par[u] = p;
subsiz[u] = 1;
trav(v,adj[u]){
if(v == p) conts;
dfs(v,u,dfs);
subsiz[u] += subsiz[v];
}
};
dfs(r,-1,dfs);
while(!cnt){
cnt = visit(par[curr]);
curr = par[curr];
}
while(true){
vector<pii> ord;
trav(v,adj[curr]){
if(v == par[curr]) conts;
ord.pb({subsiz[v],v});
}
sort(rall(ord));
int nxt = -1;
for(auto [s,v] : ord){
int x = visit(v);
if(x){
nxt = v;
break;
}
visit(curr);
}
if(nxt == -1) break;
curr = nxt;
}
// int x;
// x = visit(3);
// if (x != 2) {
// return;
// }
// x = visit(1);
// if (x != 0) {
// return;
// }
// x = visit(3);
// if (x != 2) {
// return;
// }
// x = visit(2);
// if (x != 2) {
// return;
// }
// return;
}
Compilation message
interface.cpp: In function 'int main()':
interface.cpp:44:55: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
44 | if(fread(T.data(), sizeof(int), 2 * N - 2, stdin) != 2 * N - 2) exit(0);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
interface.cpp:50:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | int l = (numbers.size() == N ? N : 0);
| ~~~~~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
764 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
191 ms |
10584 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
8092 KB |
Correct |
2 |
Correct |
82 ms |
8024 KB |
Correct |
3 |
Correct |
81 ms |
8024 KB |
Correct |
4 |
Correct |
95 ms |
9404 KB |
Correct |
5 |
Correct |
139 ms |
9316 KB |
Correct |
6 |
Correct |
185 ms |
9384 KB |
Correct |
7 |
Correct |
71 ms |
7760 KB |
Correct |
8 |
Correct |
76 ms |
7840 KB |
Correct |
9 |
Correct |
86 ms |
7580 KB |
Correct |
10 |
Correct |
68 ms |
7496 KB |
Correct |
11 |
Correct |
63 ms |
7516 KB |
Correct |
12 |
Correct |
80 ms |
7768 KB |
Correct |
13 |
Correct |
71 ms |
7508 KB |
Correct |
14 |
Correct |
50 ms |
6136 KB |
Correct |
15 |
Correct |
53 ms |
5792 KB |
Correct |
16 |
Correct |
69 ms |
7752 KB |
Correct |
17 |
Correct |
92 ms |
7620 KB |
Correct |
18 |
Correct |
75 ms |
7512 KB |
Correct |
19 |
Correct |
77 ms |
7764 KB |
Correct |
20 |
Correct |
59 ms |
5880 KB |
Correct |
21 |
Correct |
56 ms |
5976 KB |
Correct |
22 |
Correct |
47 ms |
6136 KB |
Correct |
23 |
Correct |
52 ms |
5796 KB |
Correct |
24 |
Correct |
56 ms |
5880 KB |
Correct |
25 |
Correct |
48 ms |
5888 KB |
Correct |
26 |
Correct |
79 ms |
8092 KB |
Correct |
27 |
Correct |
83 ms |
7536 KB |
Correct |
28 |
Correct |
78 ms |
7768 KB |
Correct |
29 |
Correct |
69 ms |
7584 KB |
Correct |
30 |
Correct |
76 ms |
7836 KB |
Correct |
31 |
Correct |
81 ms |
7524 KB |
Correct |
32 |
Correct |
83 ms |
7920 KB |
Correct |
33 |
Correct |
70 ms |
7756 KB |
Correct |
34 |
Correct |
77 ms |
8012 KB |
Correct |
35 |
Correct |
78 ms |
7580 KB |
Correct |
36 |
Correct |
79 ms |
7956 KB |
Correct |
37 |
Correct |
84 ms |
7836 KB |
Correct |
38 |
Correct |
81 ms |
7504 KB |
Correct |
39 |
Correct |
67 ms |
7776 KB |
Correct |
40 |
Correct |
95 ms |
7768 KB |
Correct |
41 |
Correct |
81 ms |
7836 KB |
Correct |
42 |
Correct |
74 ms |
7784 KB |
Correct |
43 |
Correct |
81 ms |
8016 KB |
Correct |
44 |
Correct |
84 ms |
7776 KB |
Correct |
45 |
Correct |
71 ms |
7580 KB |
Correct |
46 |
Correct |
87 ms |
7976 KB |
Correct |
47 |
Correct |
86 ms |
7940 KB |
Correct |
48 |
Correct |
81 ms |
7780 KB |
Correct |
49 |
Correct |
76 ms |
7580 KB |
Correct |
50 |
Correct |
82 ms |
7772 KB |
Correct |
51 |
Correct |
79 ms |
7844 KB |
Correct |
52 |
Correct |
73 ms |
7772 KB |
Correct |
53 |
Correct |
80 ms |
7836 KB |
Correct |
54 |
Correct |
86 ms |
7760 KB |
Correct |
55 |
Correct |
71 ms |
7496 KB |
Correct |
56 |
Correct |
75 ms |
7936 KB |
Correct |
57 |
Correct |
78 ms |
7880 KB |
Correct |
58 |
Correct |
82 ms |
7844 KB |
Correct |
59 |
Correct |
80 ms |
8032 KB |
Correct |
60 |
Correct |
74 ms |
7508 KB |
Correct |
61 |
Correct |
67 ms |
7668 KB |
Correct |
62 |
Correct |
83 ms |
7760 KB |
Correct |
63 |
Correct |
82 ms |
7836 KB |
Correct |
64 |
Correct |
76 ms |
8032 KB |
Correct |
65 |
Correct |
81 ms |
7768 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
764 KB |
Correct |
2 |
Incorrect |
191 ms |
10584 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |