Submission #655924

# Submission time Handle Problem Language Result Execution time Memory
655924 2022-11-06T05:50:47 Z mahatma_muhammad Network (BOI15_net) C++14
100 / 100
635 ms 84272 KB
#include <bits/stdc++.h>
#include <math.h>
//in the name of god,aka allah
//**gray sety orz**
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define pi pair<long long , long long>
#define pii pair<long long , pair<long long , long long>>
const int maxm = 5e5 +4;
const long long mod = 1e9 + 7 ;
typedef long long ll;
ll l,r,mid;
ll n,m;
ll dis[maxm] , sum[maxm];
bool isval(int mid){
    //cout << mid <<" " << mid*mid-mid <<endl;
    if (((mid-1)*mid)/2 < m) return 0;
    return 1;
}
int darage[maxm] , ss , mm;
queue<int> q;
vector<int> g[maxm] , z[maxm];
ll sath[maxm];
bool vis[maxm] , gos[maxm];
int pedaret[maxm];
ll get_par(ll v){
    if (pedaret[v]==v) return v;
    return pedaret[v] = get_par(pedaret[v]);
}
ll pars1[maxm] , pars2[maxm];
vector<ll> se[maxm];
map<int,int> st[maxm];
int rp[maxm];
pi w[maxm];
ll dp[maxm];
//ll rw[maxm][maxm];
map<ll,ll> mp;
vector<int> vec;
void dfs(int k,int jad = 1){
    for (auto x : g[k]){
        if (jad!=x) dfs(x,k);
    }
    if (g[k].size()==1) vec.push_back(k);
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >>n;
    for (int i=1; i<n; i++){
        cin >>l>>r;
        g[l].push_back(r),g[r].push_back(l); 
    }
    dfs(1);
    cout<<(vec.size()+1)/2<<endl;
    if (vec.size()%2==0){
        for (int i=0; i<vec.size()/2; i++) cout<<vec[i]<<" "<<vec[i+vec.size()/2]<<endl;
    }
    else{
        for (int i=0; i<vec.size()/2; i++) cout<<vec[i]<<" "<<vec[i+vec.size()/2+1]<<endl;
        cout<<vec[0]<<" "<<vec[vec.size()/2];
    }
}

Compilation message

net.cpp:5: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    5 | #pragma comment(linker, "/stack:200000000")
      | 
net.cpp: In function 'int main()':
net.cpp:57:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (int i=0; i<vec.size()/2; i++) cout<<vec[i]<<" "<<vec[i+vec.size()/2]<<endl;
      |                       ~^~~~~~~~~~~~~
net.cpp:60:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for (int i=0; i<vec.size()/2; i++) cout<<vec[i]<<" "<<vec[i+vec.size()/2+1]<<endl;
      |                       ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 27 ms 58964 KB Output is correct
2 Correct 27 ms 59016 KB Output is correct
3 Correct 27 ms 59036 KB Output is correct
4 Correct 28 ms 58972 KB Output is correct
5 Correct 28 ms 58924 KB Output is correct
6 Correct 28 ms 58964 KB Output is correct
7 Correct 27 ms 59020 KB Output is correct
8 Correct 27 ms 59008 KB Output is correct
9 Correct 28 ms 58952 KB Output is correct
10 Correct 27 ms 59052 KB Output is correct
11 Correct 28 ms 58952 KB Output is correct
12 Correct 27 ms 58964 KB Output is correct
13 Correct 27 ms 58964 KB Output is correct
14 Correct 27 ms 58956 KB Output is correct
15 Correct 28 ms 59024 KB Output is correct
16 Correct 27 ms 58964 KB Output is correct
17 Correct 27 ms 58940 KB Output is correct
18 Correct 27 ms 59040 KB Output is correct
19 Correct 27 ms 59032 KB Output is correct
20 Correct 27 ms 58940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 58964 KB Output is correct
2 Correct 27 ms 59016 KB Output is correct
3 Correct 27 ms 59036 KB Output is correct
4 Correct 28 ms 58972 KB Output is correct
5 Correct 28 ms 58924 KB Output is correct
6 Correct 28 ms 58964 KB Output is correct
7 Correct 27 ms 59020 KB Output is correct
8 Correct 27 ms 59008 KB Output is correct
9 Correct 28 ms 58952 KB Output is correct
10 Correct 27 ms 59052 KB Output is correct
11 Correct 28 ms 58952 KB Output is correct
12 Correct 27 ms 58964 KB Output is correct
13 Correct 27 ms 58964 KB Output is correct
14 Correct 27 ms 58956 KB Output is correct
15 Correct 28 ms 59024 KB Output is correct
16 Correct 27 ms 58964 KB Output is correct
17 Correct 27 ms 58940 KB Output is correct
18 Correct 27 ms 59040 KB Output is correct
19 Correct 27 ms 59032 KB Output is correct
20 Correct 27 ms 58940 KB Output is correct
21 Correct 26 ms 58964 KB Output is correct
22 Correct 29 ms 59084 KB Output is correct
23 Correct 29 ms 59056 KB Output is correct
24 Correct 29 ms 59008 KB Output is correct
25 Correct 28 ms 59020 KB Output is correct
26 Correct 28 ms 59116 KB Output is correct
27 Correct 28 ms 59040 KB Output is correct
28 Correct 29 ms 59028 KB Output is correct
29 Correct 30 ms 59092 KB Output is correct
30 Correct 27 ms 58972 KB Output is correct
31 Correct 29 ms 59100 KB Output is correct
32 Correct 27 ms 58964 KB Output is correct
33 Correct 29 ms 58964 KB Output is correct
34 Correct 27 ms 59052 KB Output is correct
35 Correct 27 ms 58956 KB Output is correct
36 Correct 28 ms 58980 KB Output is correct
37 Correct 27 ms 58964 KB Output is correct
38 Correct 27 ms 59012 KB Output is correct
39 Correct 27 ms 58964 KB Output is correct
40 Correct 27 ms 59060 KB Output is correct
41 Correct 27 ms 59040 KB Output is correct
42 Correct 30 ms 58972 KB Output is correct
43 Correct 29 ms 59092 KB Output is correct
44 Correct 27 ms 58912 KB Output is correct
45 Correct 27 ms 58964 KB Output is correct
46 Correct 28 ms 58956 KB Output is correct
47 Correct 29 ms 59056 KB Output is correct
48 Correct 32 ms 58936 KB Output is correct
49 Correct 28 ms 58972 KB Output is correct
50 Correct 27 ms 58964 KB Output is correct
51 Correct 27 ms 59044 KB Output is correct
52 Correct 28 ms 58952 KB Output is correct
53 Correct 28 ms 59036 KB Output is correct
54 Correct 28 ms 58948 KB Output is correct
55 Correct 27 ms 59016 KB Output is correct
56 Correct 28 ms 58976 KB Output is correct
57 Correct 28 ms 59016 KB Output is correct
58 Correct 29 ms 59124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 58964 KB Output is correct
2 Correct 27 ms 59016 KB Output is correct
3 Correct 27 ms 59036 KB Output is correct
4 Correct 28 ms 58972 KB Output is correct
5 Correct 28 ms 58924 KB Output is correct
6 Correct 28 ms 58964 KB Output is correct
7 Correct 27 ms 59020 KB Output is correct
8 Correct 27 ms 59008 KB Output is correct
9 Correct 28 ms 58952 KB Output is correct
10 Correct 27 ms 59052 KB Output is correct
11 Correct 28 ms 58952 KB Output is correct
12 Correct 27 ms 58964 KB Output is correct
13 Correct 27 ms 58964 KB Output is correct
14 Correct 27 ms 58956 KB Output is correct
15 Correct 28 ms 59024 KB Output is correct
16 Correct 27 ms 58964 KB Output is correct
17 Correct 27 ms 58940 KB Output is correct
18 Correct 27 ms 59040 KB Output is correct
19 Correct 27 ms 59032 KB Output is correct
20 Correct 27 ms 58940 KB Output is correct
21 Correct 26 ms 58964 KB Output is correct
22 Correct 29 ms 59084 KB Output is correct
23 Correct 29 ms 59056 KB Output is correct
24 Correct 29 ms 59008 KB Output is correct
25 Correct 28 ms 59020 KB Output is correct
26 Correct 28 ms 59116 KB Output is correct
27 Correct 28 ms 59040 KB Output is correct
28 Correct 29 ms 59028 KB Output is correct
29 Correct 30 ms 59092 KB Output is correct
30 Correct 27 ms 58972 KB Output is correct
31 Correct 29 ms 59100 KB Output is correct
32 Correct 27 ms 58964 KB Output is correct
33 Correct 29 ms 58964 KB Output is correct
34 Correct 27 ms 59052 KB Output is correct
35 Correct 27 ms 58956 KB Output is correct
36 Correct 28 ms 58980 KB Output is correct
37 Correct 27 ms 58964 KB Output is correct
38 Correct 27 ms 59012 KB Output is correct
39 Correct 27 ms 58964 KB Output is correct
40 Correct 27 ms 59060 KB Output is correct
41 Correct 27 ms 59040 KB Output is correct
42 Correct 30 ms 58972 KB Output is correct
43 Correct 29 ms 59092 KB Output is correct
44 Correct 27 ms 58912 KB Output is correct
45 Correct 27 ms 58964 KB Output is correct
46 Correct 28 ms 58956 KB Output is correct
47 Correct 29 ms 59056 KB Output is correct
48 Correct 32 ms 58936 KB Output is correct
49 Correct 28 ms 58972 KB Output is correct
50 Correct 27 ms 58964 KB Output is correct
51 Correct 27 ms 59044 KB Output is correct
52 Correct 28 ms 58952 KB Output is correct
53 Correct 28 ms 59036 KB Output is correct
54 Correct 28 ms 58948 KB Output is correct
55 Correct 27 ms 59016 KB Output is correct
56 Correct 28 ms 58976 KB Output is correct
57 Correct 28 ms 59016 KB Output is correct
58 Correct 29 ms 59124 KB Output is correct
59 Correct 449 ms 76948 KB Output is correct
60 Correct 558 ms 79028 KB Output is correct
61 Correct 29 ms 59092 KB Output is correct
62 Correct 26 ms 58916 KB Output is correct
63 Correct 464 ms 75200 KB Output is correct
64 Correct 28 ms 59332 KB Output is correct
65 Correct 35 ms 60340 KB Output is correct
66 Correct 156 ms 70236 KB Output is correct
67 Correct 418 ms 83552 KB Output is correct
68 Correct 434 ms 84272 KB Output is correct
69 Correct 46 ms 59656 KB Output is correct
70 Correct 205 ms 66164 KB Output is correct
71 Correct 635 ms 82152 KB Output is correct
72 Correct 553 ms 81324 KB Output is correct
73 Correct 171 ms 64340 KB Output is correct
74 Correct 541 ms 78012 KB Output is correct
75 Correct 84 ms 61628 KB Output is correct
76 Correct 556 ms 81812 KB Output is correct
77 Correct 534 ms 82068 KB Output is correct
78 Correct 57 ms 61552 KB Output is correct
79 Correct 429 ms 82300 KB Output is correct
80 Correct 33 ms 59212 KB Output is correct
81 Correct 181 ms 66112 KB Output is correct
82 Correct 541 ms 80016 KB Output is correct
83 Correct 537 ms 78144 KB Output is correct
84 Correct 510 ms 78056 KB Output is correct
85 Correct 518 ms 78004 KB Output is correct
86 Correct 565 ms 79136 KB Output is correct
87 Correct 557 ms 79036 KB Output is correct