답안 #170847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170847 2019-12-26T14:36:41 Z juggernaut 관광지 (IZhO14_shymbulak) C++14
0 / 100
1500 ms 10352 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int mx,cnt,n,x,y,i;
bool vis[200001];
vector<vector<int>>g(200001);
void dfs(int v,int cost){
    vis[v]=1;
    if(cost>mx){
        mx=cost;
        cnt=1;
    }else if(cost==mx)cnt++;
    for(int to:g[v])
        if(!vis[to])dfs(to,cost+1);
    vis[v]=0;
}
main(){
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld%lld",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(i=0;i<n;i++)dfs(i+1,0);
    printf("%lld",cnt>>1);
}

Compilation message

shymbulak.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
shymbulak.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4984 KB Output is correct
2 Incorrect 6 ms 4984 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 5240 KB Output is correct
2 Incorrect 12 ms 5112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1554 ms 10352 KB Time limit exceeded
2 Halted 0 ms 0 KB -