Submission #1017989

# Submission time Handle Problem Language Result Execution time Memory
1017989 2024-07-09T12:22:45 Z PAndaS Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"

#define pib pair<int, bool>

void count_routes(int n, int m, int p, int r[][2], int q, int g[]){
    vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0));

    for(int i = 0; i < M; i++){
        gr[r[i][0]].push_back(pair<int, int>(i, r[i][1]));
        gr[r[i][1]].push_back(pair<int, int>(i, r[i][0]));
    }

    vector< vector< vector<pib> > > jmp(n, vector< vector<pib> >(18, vector< pair<int, bool> >(2)));

    for(int i = 0; i < n; i++){
        if(!gr[i].size()){
            jmp[i][0][0] = pib(i, 1);
            jmp[i][0][1] = pib(i, 1);
        }
        jmp[i][0][0] = pib(gr[i][0].second, 0);
        if(gr[jmp[i][0][0].first][0].second == i){
            jmp[i][0][0].second = 1;
        }
        if(gr[i].size() == 1)  jmp[i][0][1] = jmp[i][0][0];
        else{
            jmp[i][0][1] = pib(gr[i][1].second, 0);
            if(gr[jmp[i][0][1].first][0].second == i) jmp[i][0][1].second = 1;
        }
    }

    for(int j = 1; j < 18; j++){
        for(int i = 0; i < n; i++){
            jmp[i][j][0] = jmp[jmp[i][j - 1][0].first][j - 1][jmp[i][j - 1][0].second];
            jmp[i][j][1] = jmp[jmp[i][j - 1][1].first][j - 1][jmp[i][j - 1][1].second];
        }
    }

    for(int j = 0; j < 3; j++){
        for(int i = 0; i < n; i++) cout << i << ' ' << j << ' ' << jmp[i][j][0].first << ' ' << jmp[i][j][0].second << ' ' << jmp[i][j][1].first << ' ' << jmp[i][j][1].second << '\n';
    }
    cout << '\n';
    int cur_n, cur_s, cnt = 0, tmp, tmp2, tmp3, tmp4;

    for(int i = 0; i < q; i++){
        cnt = 0;
        for(int j = 0; j < n; j++){
            tmp = g[i];
            cur_n = j;
            cur_s = 0;
            tmp2 = 1;
            while(tmp){
                if(tmp & tmp2){
                    tmp3 = cur_n;
                    tmp4 = cur_s;
                    cout << cur_n << ' ' << cur_s << ' ';
                    cur_n = jmp[tmp3][tmp2 - 1][tmp4].first;
                    cur_s = jmp[tmp3][tmp2 - 1][tmp4].second;
                    tmp -= tmp2;
                }
                tmp2 <<= 1;
            }
            cout << cur_n << ' ' << cur_s << '\n';
            if(cur_n == p) cnt++;
        }
        answer(cnt);
    }
}



Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:8:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    8 |     vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0));
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from garden.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
garden.cpp:8:19: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    8 |     vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0));
      |                   ^~~~
      |                   std::pair
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: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
garden.cpp:8:24: error: expected primary-expression before 'int'
    8 |     vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0));
      |                        ^~~
garden.cpp:10:24: error: 'M' was not declared in this scope
   10 |     for(int i = 0; i < M; i++){
      |                        ^
garden.cpp:11:9: error: 'gr' was not declared in this scope; did you mean 'r'?
   11 |         gr[r[i][0]].push_back(pair<int, int>(i, r[i][1]));
      |         ^~
      |         r
garden.cpp:11:36: error: expected primary-expression before 'int'
   11 |         gr[r[i][0]].push_back(pair<int, int>(i, r[i][1]));
      |                                    ^~~
garden.cpp:11:41: error: expected primary-expression before 'int'
   11 |         gr[r[i][0]].push_back(pair<int, int>(i, r[i][1]));
      |                                         ^~~
garden.cpp:12:36: error: expected primary-expression before 'int'
   12 |         gr[r[i][1]].push_back(pair<int, int>(i, r[i][0]));
      |                                    ^~~
garden.cpp:12:41: error: expected primary-expression before 'int'
   12 |         gr[r[i][1]].push_back(pair<int, int>(i, r[i][0]));
      |                                         ^~~
garden.cpp:5:18: error: expected primary-expression before 'int'
    5 | #define pib pair<int, bool>
      |                  ^~~
garden.cpp:15:28: note: in expansion of macro 'pib'
   15 |     vector< vector< vector<pib> > > jmp(n, vector< vector<pib> >(18, vector< pair<int, bool> >(2)));
      |                            ^~~
garden.cpp:18:13: error: 'gr' was not declared in this scope; did you mean 'r'?
   18 |         if(!gr[i].size()){
      |             ^~
      |             r
garden.cpp:19:13: error: 'jmp' was not declared in this scope
   19 |             jmp[i][0][0] = pib(i, 1);
      |             ^~~
garden.cpp:5:18: error: expected primary-expression before 'int'
    5 | #define pib pair<int, bool>
      |                  ^~~
garden.cpp:19:28: note: in expansion of macro 'pib'
   19 |             jmp[i][0][0] = pib(i, 1);
      |                            ^~~
garden.cpp:5:18: error: expected primary-expression before 'int'
    5 | #define pib pair<int, bool>
      |                  ^~~
garden.cpp:20:28: note: in expansion of macro 'pib'
   20 |             jmp[i][0][1] = pib(i, 1);
      |                            ^~~
garden.cpp:22:9: error: 'jmp' was not declared in this scope
   22 |         jmp[i][0][0] = pib(gr[i][0].second, 0);
      |         ^~~
garden.cpp:5:18: error: expected primary-expression before 'int'
    5 | #define pib pair<int, bool>
      |                  ^~~
garden.cpp:22:24: note: in expansion of macro 'pib'
   22 |         jmp[i][0][0] = pib(gr[i][0].second, 0);
      |                        ^~~
garden.cpp:23:12: error: 'gr' was not declared in this scope; did you mean 'r'?
   23 |         if(gr[jmp[i][0][0].first][0].second == i){
      |            ^~
      |            r
garden.cpp:26:12: error: 'gr' was not declared in this scope; did you mean 'r'?
   26 |         if(gr[i].size() == 1)  jmp[i][0][1] = jmp[i][0][0];
      |            ^~
      |            r
garden.cpp:5:18: error: expected primary-expression before 'int'
    5 | #define pib pair<int, bool>
      |                  ^~~
garden.cpp:28:28: note: in expansion of macro 'pib'
   28 |             jmp[i][0][1] = pib(gr[i][1].second, 0);
      |                            ^~~
garden.cpp:35:13: error: 'jmp' was not declared in this scope
   35 |             jmp[i][j][0] = jmp[jmp[i][j - 1][0].first][j - 1][jmp[i][j - 1][0].second];
      |             ^~~
garden.cpp:41:36: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   41 |         for(int i = 0; i < n; i++) cout << i << ' ' << j << ' ' << jmp[i][j][0].first << ' ' << jmp[i][j][0].second << ' ' << jmp[i][j][1].first << ' ' << jmp[i][j][1].second << '\n';
      |                                    ^~~~
      |                                    std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from garden.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
garden.cpp:41:68: error: 'jmp' was not declared in this scope
   41 |         for(int i = 0; i < n; i++) cout << i << ' ' << j << ' ' << jmp[i][j][0].first << ' ' << jmp[i][j][0].second << ' ' << jmp[i][j][1].first << ' ' << jmp[i][j][1].second << '\n';
      |                                                                    ^~~
garden.cpp:43:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   43 |     cout << '\n';
      |     ^~~~
      |     std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from garden.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
garden.cpp:58:29: error: 'jmp' was not declared in this scope; did you mean 'tmp'?
   58 |                     cur_n = jmp[tmp3][tmp2 - 1][tmp4].first;
      |                             ^~~
      |                             tmp