Submission #1059756

#TimeUsernameProblemLanguageResultExecution timeMemory
1059756Cyanberry열대 식물원 (Tropical Garden) (IOI11_garden)C++14
Compilation error
0 ms0 KiB
    #include <bits/stdc++.h>
    using namespace std;
    #include "gardenlib.h"
     
    void count_routes(int fountains, int pathCount, int dest, int[][2] paths, int groupCount, int groups[]) {
        vector<vector<int>> graf(pathCount, vector<int>{});
        for (int i = 0; i < paths.size(); ++i) {
            graf[paths[i][0]].push_back(paths[i][1]);
            graf[paths[i][1]].push_back(paths[i][0]);
        }
        for (vector<int> i : graf) {
            for (int j : i) {
                // cout<<j<<' ';
            }
            // cout<<'\n';
        }
        vector<int> lengths(pathCount, 0);
        for (int i = 0; i < pathCount; ++i) {
            if (lengths[i] == 0) {
                int counting = -1, curr = i, prev = -1, dist;
                // cout<<'+'<<i<<'\n';
                while (curr != dest) {
                    lengths[curr] = counting;
                    if (prev != graf[curr][0] || graf[curr].size() == 1) {
                        prev = curr;
                        curr = graf[curr][0];
                    } else {
                        prev = curr;
                        curr = graf[curr][1];
                    }
                    // cout<<counting<<'\n';
                    --counting;
                    if (lengths[curr] > 0) {
                        dist = lengths[curr] - counting + 1;
                        break;
                    }
                    if (lengths[curr] < 0 && lengths[curr] - counting > 2) {
                        dist = -1;
                        break;
                    }
                    if (curr == dest) {
                        dist = -counting;
                        break;
                    }
                    
                }
                curr = i, prev = -1;
                if (dist < 0) continue;
                while (curr != dest) {
                    if (lengths[curr] < 0) lengths[curr] += dist;
                    if (prev != graf[curr][0] || graf[curr].size() == 1) {
                        prev = curr;
                        curr = graf[curr][0];
                    } else {
                        prev = curr;
                        lengths[curr] += 2;
                        curr = graf[curr][1];
                    }
                    if (lengths[curr] > 0) {
                        break;
                    }
                    if (curr == dest) {
                        break;
                    }
                }
            }
        }
        int counting = 0, curr = dest, prev = -1;
        while (true) {
            if (prev != graf[curr][0] || graf[curr].size() == 1) {
                prev = curr;
                curr = graf[curr][0];
            } else {
                prev = curr;
                curr = graf[curr][1];
            }
            ++counting;
            if (curr == dest) {
                break;
            }
        }
        vector<int> answers(150010, 0);
        for (int i = 0; i < lengths.size(); ++i) {
            if (lengths[i] > 0) ++answers[lengths[i]];
        }
        for (int i = 0; i < counting; ++i) {
            for (int j = i; j < 150010; j += counting) {
                if (j > i) {
                    answers[j] += answers[j - counting];
                }
            }
        }
        for (int it = 0; it < groupCount; ++it) {
            int i = groups[it];
            if (i < 150010) answer(answers[i]);
            else {
                i -= 150010;
                i %= counting;
                i -= counting;
                i += 150010;
                answer(answers[i]);
            }
        }
    }

Compilation message (stderr)

garden.cpp:5:72: error: expected ',' or '...' before 'paths'
    5 |     void count_routes(int fountains, int pathCount, int dest, int[][2] paths, int groupCount, int groups[]) {
      |                                                                        ^~~~~
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2])':
garden.cpp:7:29: error: 'paths' was not declared in this scope
    7 |         for (int i = 0; i < paths.size(); ++i) {
      |                             ^~~~~
garden.cpp:12:22: warning: unused variable 'j' [-Wunused-variable]
   12 |             for (int j : i) {
      |                      ^
garden.cpp:83:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         for (int i = 0; i < lengths.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~~~~
garden.cpp:93:31: error: 'groupCount' was not declared in this scope
   93 |         for (int it = 0; it < groupCount; ++it) {
      |                               ^~~~~~~~~~
garden.cpp:94:21: error: 'groups' was not declared in this scope
   94 |             int i = groups[it];
      |                     ^~~~~~