Submission #1086365

# Submission time Handle Problem Language Result Execution time Memory
1086365 2024-09-10T10:30:50 Z akacool445k Tropical Garden (IOI11_garden) C++14
49 / 100
5000 ms 6236 KB
#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
// #define int long long
#define pint pair<int, int>
#define vint vector<pair<int, int>>
const int mod = 1e9 + 7;
const int shrek = 2e5 + 5;
const int say = INT_MAX;
const int gex = INT_MIN;
vector<vector<int>> adj(shrek); 

void count_routes(int n, int m, int p, int r[][2], int q, int g[]) {
    int a, b;
    for(int i = 0; i < m; i++) {
        a = r[i][0];
        b = r[i][1];
        if(adj[a].size() < 2) adj[a].pb(b);
        if(adj[b].size() < 2) adj[b].pb(a);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int cur = i;
        int par = -1;
        for(int cnt = 0; cnt < g[0]; cnt++) {
            if(adj[cur].size() == 1) {
                par = cur;
                cur = adj[cur][0];
                continue;
            }
            if(par != adj[cur][0]) {
                par = cur;
                cur = adj[cur][0];
                continue;
            } else {
                par = cur;
                cur = adj[cur][1];
                continue;
            } 
        }
        if(cur == p) ans++;
    }
    // if(ans != 1) exit(1);
    for(int i = 0; i < q; i++) answer(ans);
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 5212 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Execution timed out 5054 ms 6236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 5212 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Execution timed out 5054 ms 6236 KB Time limit exceeded
12 Halted 0 ms 0 KB -