답안 #344650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344650 2021-01-06T07:06:36 Z bachaquer 관광지 (IZhO14_shymbulak) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
 
using namespace std;
 
ll n, x, m, y;

vector<vector<ll>> v;

ll was[1000];

ll rast = 0, mx = -1, sum = 0;

void dfs (ll n) {
    was[n] = 1;
    rast++;
    for (int i = 0; i < v[n].size(); i++) {
        if (!was[i]) dfs(v[n][i]);
    }
    if (rast > mx) {
        mx = rast;
        sum = 1;
    }
    else if (rast == mx) {
        sum++;
    }
    rast--;
    was[n] = 0;
} 

int main() {
    cin >> n;
    vector<ll> v[n];
    for (int i = 0; i <= n; i++) {
        v.pb({});
    }
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for (int j = 1; j <= n; j++) {
        dfs(j);
    }
    cout << sum;
    return 0;
}

Compilation message

shymbulak.cpp: In function 'void dfs(long long int)':
shymbulak.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < v[n].size(); i++) {
      |                     ~~^~~~~~~~~~~~~
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:4:12: error: request for member 'push_back' in 'v', which is of non-class type 'std::vector<long long int> [n]'
    4 | #define pb push_back
      |            ^~~~~~~~~
shymbulak.cpp:37:11: note: in expansion of macro 'pb'
   37 |         v.pb({});
      |           ^~