Submission #963045

# Submission time Handle Problem Language Result Execution time Memory
963045 2024-04-14T11:59:12 Z Amr Tropical Garden (IOI11_garden) C++17
0 / 100
1 ms 348 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(),(x).end()
const int N = 1002;
vector<pair<ll,ll> > v[N];
ll lst[N];
vector<ll> vec;
ll vis[N];
void dfs1(ll x)
{
    if(vis[x]) return;
    vis[x] = 1;
    vec.push_back(x);
    for(int i = 0; i < v[x].sz; i++)
    {
        dfs1(v[x][i].S);
    }
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
    for(int i = 0; i < M; i++)
    {
        ll x = R[i][0] , y = R[i][1];
        v[x].push_back({i,y});
        v[y].push_back({i,x});
    }
    for(int i = 0; i < N; i++) sort(all(v[i]));


    dfs1(P);
    if(vec.sz==2)
    {
        answer(1);
        return;
    }
    ll ans = 0;
    for(int i = 0; i < vec.sz; i++)
    {

        ll x = vec[i],par=N;
        for(int i = 0; i < N; i++) lst[i] = 0;
        //cout << x << ": " << endl;
        ll cnt= G[0];
        while(cnt--)
        {
            //cout << x << " ";
            ll y = v[x][lst[x]].S;
            if(v[x].sz==1) {par = x, x = y;  continue;}

                if(y!=par) lst[par] = 0;
                lst[x] = (lst[x]+1)%2;
                par = x;
                x = y;
        }
        if(x==P) ans++;

    }
    answer(ans); return;
}


Compilation message

garden.cpp: In function 'void dfs1(ll)':
garden.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i < v[x].sz; i++)
      |                      ^
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 0; i < vec.sz; i++)
      |                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -