Submission #737744

# Submission time Handle Problem Language Result Execution time Memory
737744 2023-05-07T16:47:12 Z rominanafu Tropical Garden (IOI11_garden) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pii pair<int,int>

using namespace std;

int n, m, fin;
int a, b;
pii sig[1005];
int queries, caso, resp;
int dist[1005][3];

int cant_rutas(int ant, int act, int sum) {
    if (act == fin && sum == caso)
        return 1;
    if (sum > caso)
        return 0;
    int r=0;
    if (sig[act].first != ant || sig[act].second == -1)
        r = cant_rutas(act, sig[act].first, sum+1);
    else
        r = cant_rutas(act, sig[act].second, sum+1);
    return r;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dist, -1, sizeof(dist));
    memset(sig, -1, sizeof(sig));
    cin >> n >> m; /// trail 0 > trail 1 > trail 2... (in beauty)
    cin >> fin;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        if (sig[a].first == -1) {
            sig[a].first = b;
        } else if (sig[a].second == -1) {
            sig[a].second = b;
        }
        if (sig[b].first == -1) {
            sig[b].first = a;
        } else if (sig[b].second == -1) {
            sig[b].second = a;
        }
    }
    cin >> queries;
    while (queries--) {
        cin >> caso;
        resp = 0;
        for(int i=0; i<n; i++) {
            resp += cant_rutas(-1, i, 0);
        }
        cout << resp << ' ';
    }
    return 0;
}

Compilation message

garden.cpp: In function 'int main()':
garden.cpp:30:32: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<int, int>' with no trivial copy-assignment [-Wclass-memaccess]
   30 |     memset(sig, -1, sizeof(sig));
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from garden.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'struct std::pair<int, int>' declared here
  211 |     struct pair
      |            ^~~~
/usr/bin/ld: /tmp/ccZxipsq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrTvo8p.o:garden.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccZxipsq.o: in function `main':
grader.cpp:(.text.startup+0x3f): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status