Submission #1017998

# Submission time Handle Problem Language Result Execution time Memory
1017998 2024-07-09T12:28:11 Z PAndaS Tropical Garden (IOI11_garden) C++14
0 / 100
2 ms 1112 KB
#include<bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
#define pib pair<int, bool>

using namespace std;

void count_routes(int n, int m, int p, int r[][2], int q, int g[]){
    vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0));

    for(int i = 0; i < m; i++){
        gr[r[i][0]].push_back(pair<int, int>(i, r[i][1]));
        gr[r[i][1]].push_back(pair<int, int>(i, r[i][0]));
    }

    vector< vector< vector<pib> > > jmp(n, vector< vector<pib> >(18, vector<pib>(2)));

    for(int i = 0; i < n; i++){
        if(!gr[i].size()){
            jmp[i][0][0] = pib(i, 1);
            jmp[i][0][1] = pib(i, 1);
        }
        jmp[i][0][0] = pib(gr[i][0].second, 0);
        if(gr[jmp[i][0][0].first][0].second == i){
            jmp[i][0][0].second = 1;
        }
        if(gr[i].size() == 1)  jmp[i][0][1] = jmp[i][0][0];
        else{
            jmp[i][0][1] = pib(gr[i][1].second, 0);
            if(gr[jmp[i][0][1].first][0].second == i) jmp[i][0][1].second = 1;
        }
    }

    for(int j = 1; j < 18; j++){
        for(int i = 0; i < n; i++){
            jmp[i][j][0] = jmp[jmp[i][j - 1][0].first][j - 1][jmp[i][j - 1][0].second];
            jmp[i][j][1] = jmp[jmp[i][j - 1][1].first][j - 1][jmp[i][j - 1][1].second];
        }
    }

    for(int j = 0; j < 3; j++){
        for(int i = 0; i < n; i++) cout << i << ' ' << j << ' ' << jmp[i][j][0].first << ' ' << jmp[i][j][0].second << ' ' << jmp[i][j][1].first << ' ' << jmp[i][j][1].second << '\n';
    }
    cout << '\n';
    int cur_n, cur_s, cnt = 0, tmp, tmp2, tmp3, tmp4;

    for(int i = 0; i < q; i++){
        cnt = 0;
        for(int j = 0; j < n; j++){
            tmp = g[i];
            cur_n = j;
            cur_s = 0;
            tmp2 = 0;
            while(tmp){
                if(tmp & (1 << tmp2)){
                    tmp3 = cur_n;
                    tmp4 = cur_s;
                    cout << cur_n << ' ' << cur_s << ' ';
                    cur_n = jmp[tmp3][tmp2][tmp4].first;
                    cur_s = jmp[tmp3][tmp2][tmp4].second;
                    tmp -= (1 << tmp2);
                }
                tmp2++;
            }
            cout << cur_n << ' ' << cur_s << '\n';
            if(cur_n == p) cnt++;
        }
        answer(cnt);
    }
}



# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -