Submission #587049

# Submission time Handle Problem Language Result Execution time Memory
587049 2022-07-01T09:16:05 Z MohamedFaresNebili Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")

                using namespace std;

                using ll = long long;
                using ii = pair<ll, ll>;
                using vi = vector<int>;

                #define ff first
                #define ss second
                #define pb push_back
                #define all(x) (x).begin(), (x).end()
                #define lb lower_bound

                const int oo = 1000 * 1000 * 1000 + 7;

                void answer(int X) { cout << X << " "; }

                int C[2], to[300005], D[300005], DD[300005];
                int vis[300005], Vis[300005];
                vector<int> adj[300005], E[300005];

                void solve(int v) {
                    queue<int> Q; Q.push(v); D[v] = 0; int u = v;
                    while(vis[u] == 0) {
                        vis[u] = 1; u = to[u];
                    }
                    while(vis[u] != 2) {
                        vis[u] = 2; u = to[u]; C[0]++;
                    }
                    if(vis[v] != 2) C[0] = -1;

                    while(!Q.empty()) {
                        int A = Q.front(); Q.pop();
                        for(auto e : adj[A]) {
                            if(D[e] <= D[A] + 1) continue;
                            D[e] = D[A] + 1; Q.push(e);
                        }
                    }

                }
                void Solve(int v) {
                    queue<int> Q; Q.push(v); DD[v] = 0; int u = v;
                    while(Vis[u] == 0) {
                        Vis[u] = 1; u = to[u];
                    }
                    while(Vis[u] != 2) {
                        Vis[u] = 2; u = to[u]; C[1]++;
                    }
                    if(Vis[v] != 2) C[1] = -1;

                    while(!Q.empty()) {
                        int A = Q.front(); Q.pop();
                        for(auto e : adj[A]) {
                            if(DD[e] <= DD[A] + 1) continue;
                            DD[e] = DD[A] + 1; Q.push(e);
                        }
                    }
                }

                void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
                    memset(to, -1, sizeof to);
                    fill(D, D + 2 * N, oo); fill(DD, DD + 2 * N, oo);

                    for(int l = 0; l < M; l++) {
                        int U = R[l][0], V = R[l][1];
                        if(E[U].size() < 2) E[U].pb(V);
                        if(E[V].size() < 2) E[V].pb(U);
                    }

                    for(int l = 0; l < N; l++) {
                        D[l] = DD[l] = oo;
                        for(int i = 0; i < E[l].size(); i++) {
                            int U = E[l][i];
                            if(i == 0) {
                                to[l] = U;
                                if(E[U][0] == l && E[U].size() > 1)
                                    to[l] = U + N, U += N;
                                adj[U].pb(l);
                                continue;
                            }
                            to[l + N] = U;
                            if(E[U][0] == l && E[U].size() > 1)
                                to[l + N] = U + N, U += N;
                            adj[U].pb(l + N);
                        }
                    }

                    solve(P); Solve(P + N);

                    for(int l = 0; l < Q; l++) {
                        int T = G[l]; int res = 0;
                        for(int i = 0; i < N; i++) {
                            if(C[0] == -1 && D[i] == T) res++;
                            else if(C[0] > 0 && T >= D[i] && (T - D[i]) % C[0] == 0) res++;
                            else if(C[1] == -1 & DD[i] == T) res++;
                            else if(C[1] > 0 && T >= DD[i] && (T - DD[i]) % C[1] == 0) res++;
                        }
                        answer(res);
                    }
                }

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:78:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |                         for(int i = 0; i < E[l].size(); i++) {
      |                                        ~~^~~~~~~~~~~~~
garden.cpp:101:42: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  101 |                             else if(C[1] == -1 & DD[i] == T) res++;
      |                                     ~~~~~^~~~~
/usr/bin/ld: /tmp/ccJbrMcL.o: in function `answer(int)':
grader.cpp:(.text+0x130): multiple definition of `answer(int)'; /tmp/ccR6MmdO.o:garden.cpp:(.text+0xa0): first defined here
collect2: error: ld returned 1 exit status