Submission #1051730

# Submission time Handle Problem Language Result Execution time Memory
1051730 2024-08-10T09:19:41 Z AndreasK Tropical Garden (IOI11_garden) C++17
0 / 100
1 ms 520 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;

#define designed ios_base::sync_with_stdio(0);
#define by cin.tie(0);
#define AndreasK cout.tie(0);
//#define int long long
#define ii pair <int,int>
#define vi vector <int>
#define iii pair <int,ii>
#define vii vector <ii>
#define vc vector <char>
#define vb vector <bool>

vector <vii> graph;
int ans;
void dfs(int curr,int prev,int have,int should){
if (have==should)
    ans=curr;
else if (graph[curr].size()==1){
    dfs(graph[curr][0].first,curr,have+1,should);
}
else{
    int mx=-1;
    int mxn=0;
    for (ii nxt:graph[curr]){
        if (nxt.first!=prev){
        if (nxt.second>mx){
            mxn=nxt.first;
            mx=nxt.second;
        }
        }
    }
    dfs(mxn,curr,have+1,should);
}
}

void count_routes(int n, int m, int p, int r[][2], int q, int g[])
{
graph.assign(n,vii());
for (int c=0;c<m;c++){
    graph[r[c][0]].push_back({r[c][1],n-c});
    graph[r[c][1]].push_back({r[c][0],n-c});
}
for (int r=0;r<q;r++){
    int ttl=0;
    for (int c=0;c<n;c++){
        dfs(c,c,0,g[r]);
        if (ans==p)
            ttl++;
    }
    answer(ttl);
}
}

/*int32_t main(){
    designed by AndreasK
    freopen("akinput.txt","r",stdin);
    int n,m,p;
    cin>>n>>m>>p;
    int r[m][2];
    for (int c=0;c<m;c++)
        cin>>r[c][0]>>r[c][1];
    int q;
    cin>>q;
    int g[q];
    for (auto &c:g)
        cin>>c;
    count_routes(n,m,p,r,q,g);
return 0;}*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -