Submission #1076283

# Submission time Handle Problem Language Result Execution time Memory
1076283 2024-08-26T12:32:07 Z ArthuroWich Tropical Garden (IOI11_garden) C++17
49 / 100
5000 ms 1884 KB
#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
int P, k, ans = 0;
vector<vector<int>> adj;
void calc(int i) {
    int p;
    if (adj[i].size() == 1) {
        p = adj[i][0];
    } else {
        p = adj[i][1];
    }
    int l = 0;
    int a = i, b = p;
    while(l < k) {
        if (adj[a].size() == 1) {
            b = a;
            a = adj[a][0];
        } else {
            if (adj[a][0] == b) {
                b = a;
                a = adj[a][1];
            } else {
                b = a;
                a = adj[a][0];
            }
        }
        l++;
    }
    //cout << i << " " << p << " " << a << " " << p << endl;
    if (a == P) {
        ans++;
    }
}
void count_routes(int n, int m, int pp, int R[][2], int Q, int G[]) {
    adj.resize(n+1);
    P = pp;
    for (int i = 0; i < m; i++) {
        if (adj[R[i][0]].size() < 2) {
            adj[R[i][0]].push_back(R[i][1]);
        }
        if (adj[R[i][1]].size() < 2) {
            adj[R[i][1]].push_back(R[i][0]);
        }
    }
    k = G[0];
    for (int i = 0; i < n; i++) {
        calc(i);
    }
    answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 556 KB Output is correct
10 Correct 4 ms 420 KB Output is correct
11 Execution timed out 5063 ms 1884 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 556 KB Output is correct
10 Correct 4 ms 420 KB Output is correct
11 Execution timed out 5063 ms 1884 KB Time limit exceeded
12 Halted 0 ms 0 KB -