Submission #474682

# Submission time Handle Problem Language Result Execution time Memory
474682 2021-09-19T11:34:50 Z hidden1 Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 KB
#include "gardenlib.h"
#include "garden.h"

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
    n = N;
    fill_n(mn, n, 1e8);
    for(int i = 0; i < M; i ++) {
        int a = R[i][0], b = R[i][1];
        help[a].push_back(i);
        help[b].push_back(i);
        chkmin(mn[a], i);
        chkmin(mn[b], i);
    }
    for(int i = 0; i < n; i ++) {
        sort(help[i].begin(), help[i].end());
        if(help[i].size() == 0) {
            continue;
        } else {
            // ???
            int best = help[i][0];
            par[i] = R[best][0] + R[best][1] - i;
            if(mn[par[i]] == best) {
                par[i] += n;
            }
            best = help[i][1 % help[i].size()];
            par[i + n] = R[best][0] + R[best][1] - i;
            if(mn[par[i + n]] == best) {
                par[i + n] += n;
            }
        }
    }
    for(int i = 0; i < 2 * n; i ++) {
        g[par[i]].push_back(i);
    }

    cnt[0] = cnt[1] = -1;
    fill_n(used, n, 0);
    dfs(P, 0);

    cout << endl;

    fill_n(used, n, 0);
    dfs(P + n, 1);

    for(int i = 0; i < 2; i ++) {
        if(cnt[i] == -1) {continue;}
        for(int j = cnt[i]; j < MAX_N; j ++) {
            for(auto it : ans[i][j]) {
                ans[i][it % cnt[i]].push_back(it);
            }
        }
    }

    for(int i = 0; i < Q; i ++) {
        int ret = 0;
        if(cnt[0] != -1) {
            ret += upper_bound(ans[0][G[i] % cnt[0]].begin(), ans[0][G[i] % cnt[0]].end(), G[i]) - ans[0][G[i] % cnt[0]].begin();
        } else {
            ret += ans[0][G[i]].size();
        }

        if(cnt[1] != -1) {
            ret += upper_bound(ans[1][G[i] % cnt[1]].begin(), ans[1][G[i] % cnt[1]].end(), G[i]) - ans[1][G[i] % cnt[1]].begin();
        } else {
            ret += ans[1][G[i]].size();
        }

        answer(ret);
    }
}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:5:5: error: 'n' was not declared in this scope
    5 |     n = N;
      |     ^
garden.cpp:6:12: error: 'mn' was not declared in this scope
    6 |     fill_n(mn, n, 1e8);
      |            ^~
garden.cpp:6:5: error: 'fill_n' was not declared in this scope
    6 |     fill_n(mn, n, 1e8);
      |     ^~~~~~
garden.cpp:9:9: error: 'help' was not declared in this scope
    9 |         help[a].push_back(i);
      |         ^~~~
garden.cpp:11:9: error: 'chkmin' was not declared in this scope
   11 |         chkmin(mn[a], i);
      |         ^~~~~~
garden.cpp:15:14: error: 'help' was not declared in this scope
   15 |         sort(help[i].begin(), help[i].end());
      |              ^~~~
garden.cpp:15:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |         sort(help[i].begin(), help[i].end());
      |         ^~~~
      |         short
garden.cpp:21:13: error: 'par' was not declared in this scope
   21 |             par[i] = R[best][0] + R[best][1] - i;
      |             ^~~
garden.cpp:33:9: error: 'g' was not declared in this scope
   33 |         g[par[i]].push_back(i);
      |         ^
garden.cpp:33:11: error: 'par' was not declared in this scope
   33 |         g[par[i]].push_back(i);
      |           ^~~
garden.cpp:36:5: error: 'cnt' was not declared in this scope; did you mean 'int'?
   36 |     cnt[0] = cnt[1] = -1;
      |     ^~~
      |     int
garden.cpp:37:12: error: 'used' was not declared in this scope
   37 |     fill_n(used, n, 0);
      |            ^~~~
garden.cpp:38:5: error: 'dfs' was not declared in this scope
   38 |     dfs(P, 0);
      |     ^~~
garden.cpp:40:5: error: 'cout' was not declared in this scope
   40 |     cout << endl;
      |     ^~~~
garden.cpp:40:13: error: 'endl' was not declared in this scope
   40 |     cout << endl;
      |             ^~~~
garden.cpp:47:33: error: 'MAX_N' was not declared in this scope
   47 |         for(int j = cnt[i]; j < MAX_N; j ++) {
      |                                 ^~~~~
garden.cpp:48:27: error: 'ans' was not declared in this scope
   48 |             for(auto it : ans[i][j]) {
      |                           ^~~
garden.cpp:57:32: error: 'ans' was not declared in this scope
   57 |             ret += upper_bound(ans[0][G[i] % cnt[0]].begin(), ans[0][G[i] % cnt[0]].end(), G[i]) - ans[0][G[i] % cnt[0]].begin();
      |                                ^~~
garden.cpp:57:20: error: 'upper_bound' was not declared in this scope
   57 |             ret += upper_bound(ans[0][G[i] % cnt[0]].begin(), ans[0][G[i] % cnt[0]].end(), G[i]) - ans[0][G[i] % cnt[0]].begin();
      |                    ^~~~~~~~~~~
garden.cpp:59:20: error: 'ans' was not declared in this scope
   59 |             ret += ans[0][G[i]].size();
      |                    ^~~
garden.cpp:63:32: error: 'ans' was not declared in this scope
   63 |             ret += upper_bound(ans[1][G[i] % cnt[1]].begin(), ans[1][G[i] % cnt[1]].end(), G[i]) - ans[1][G[i] % cnt[1]].begin();
      |                                ^~~
garden.cpp:63:20: error: 'upper_bound' was not declared in this scope
   63 |             ret += upper_bound(ans[1][G[i] % cnt[1]].begin(), ans[1][G[i] % cnt[1]].end(), G[i]) - ans[1][G[i] % cnt[1]].begin();
      |                    ^~~~~~~~~~~
garden.cpp:65:20: error: 'ans' was not declared in this scope
   65 |             ret += ans[1][G[i]].size();
      |                    ^~~