이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of GOD
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define BeGood ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define orset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nl '\n'
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
typedef long long ll;
typedef double db;
const int N = 1e5 + 4;
const int M = 1e9 + 7;
int n;
vector<int> t[N];
int d[N], p[N];
int jol[N], u[N];
map<int, int> ans;
int mx = 0;
void bfs(int v){
queue<int> q;
jol[v] = 1;
u[v] = 1;
q.push(v);
while(!q.empty()){
int id = q.front();
q.pop();
for(auto to : t[id]){
if(to != p[id]){
if(!u[to]){
p[to] = id;
jol[to] = jol[id] + 1;
u[id] = 1;
q.push(to);
} else{
d[jol[id] - 1]++;
}
}
}
}
}
int main(){
BeGood
cin >> n;
for(int i = 1; i <= n; ++i){
int a, b;
cin >> a >> b;
t[a].pb(b);
t[b].pb(a);
}
for(int i = 1; i <= n; ++i){
memset(jol, 0, sizeof(jol));
memset(u, 0, sizeof(u));
memset(p, 0, sizeof(p));
bfs(i);
}
for(int i = n; i >= 0; --i){
if(d[i]){
cout << d[i];
return 0;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |