답안 #1086354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086354 2024-09-10T10:07:01 Z akacool445k 열대 식물원 (Tropical Garden) (IOI11_garden) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define int long long
#define pint pair<int, int>
#define vint vector<pair<int, int>>
const int mod = 1e9 + 7;
const int shrek = 2e5 + 5;
const int say = INT_MAX;
const int gex = INT_MIN;
const int sebian = LLONG_MAX;
const int lex = LLONG_MIN;
vector<vector<int>> adj(shrek); 

void count_routes(int n, int m, int p, int r[][2], int q, int g[]) {
    int a, b;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        if(adj[a].size() < 2) adj.pb(b);
        if(adj[b].size() < 2) adj.pb(a);
    }
    int ans = 0;
    
    for(int i = 0; i < n; i++) {
        int cur = 0;
        int par = -1;
        for(int cnt = 0; cnt < g[0]; cnt++) {
            if(adj[cur].size() == 1) {
                par = cur;
                cur = adj[cur][0];
                continue;
            }
            if(par != adj[cur][0]) {
                par = cur;
                cur = adj[cur][0];
                continue;
            } else {
                par = cur;
                cur = adj[cur][1];
                continue;
            } 
        }
        if(cur == p) ans++;
    }
    // if(ans != 1) exit(1);
    for(int i = 0; i < q; i++) answer(ans);
}
// signed main() {
//     int n, m, 
// }


Compilation message

garden.cpp: In function 'void count_routes(long long int, long long int, long long int, long long int (*)[2], long long int, long long int*)':
garden.cpp:23:39: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back(long long int&)'
   23 |         if(adj[a].size() < 2) adj.pb(b);
      |                                       ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from garden.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'long long int' to 'const value_type&' {aka 'const std::vector<long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<long long int> >::value_type&&' {aka 'std::vector<long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
garden.cpp:24:39: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back(long long int&)'
   24 |         if(adj[b].size() < 2) adj.pb(a);
      |                                       ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from garden.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'long long int' to 'const value_type&' {aka 'const std::vector<long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<long long int> >::value_type&&' {aka 'std::vector<long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~