// 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
3968 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
3944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1561 ms |
8412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |