Submission #347865

# Submission time Handle Problem Language Result Execution time Memory
347865 2021-01-13T16:45:50 Z beksultan04 Tropical Garden (IOI11_garden) C++14
69 / 100
5000 ms 47340 KB
#include "garden.h"
#include "gardenlib.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin()Ñ,s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int INF=1e9+7;
int up[400001][31];
vector <int> g[200001];

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
    int i,j;
    for (i=0;i<M;++i){
        if (g[R[i][0]].size() < 2)
            g[R[i][0]].pb(R[i][1]);

        if (g[R[i][1]].size() < 2)
            g[R[i][1]].pb(R[i][0]);

    }
    for (i=0;i<2*N;++i)up[i][0]=-1;

    for (int pr=0;pr<N;++pr){
        j=0;
        for (int nd : g[pr]){
            if (g[nd][0] == pr && g[nd].size() == 2){
                up[pr+j*N][0]=nd+N;
            }
            else {
                up[pr+j*N][0]=nd;
            }
            j++;

        }
    }

    for (i=1;i<31;++i){
        for (j=0;j<2*N;++j){
            up[j][i] = up[up[j][i-1]][i-1];
        }
    }

    for (j=0;j<Q;++j){
        int k, ans=0, v;
        for (i=0;i<N;++i){
            v = i, k = G[j];
            for (int pw = 30;pw >= 0;--pw){
                if ((1 << pw) <= k){
                    k -= (1 << pw);
                    v = up[v][pw];
                }
            }
            //cout<<i<<" "<<ans<<"\n";
            if (v == P || v == P+N)ans++;
        }
        answer(ans);
    }
}


# Verdict Execution time Memory Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5356 KB Output is correct
3 Correct 4 ms 5356 KB Output is correct
4 Correct 4 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 4 ms 5356 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 4 ms 5356 KB Output is correct
9 Correct 6 ms 5356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5356 KB Output is correct
3 Correct 4 ms 5356 KB Output is correct
4 Correct 4 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 4 ms 5356 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 4 ms 5356 KB Output is correct
9 Correct 6 ms 5356 KB Output is correct
10 Correct 4 ms 5100 KB Output is correct
11 Correct 26 ms 11372 KB Output is correct
12 Correct 51 ms 15724 KB Output is correct
13 Correct 127 ms 29036 KB Output is correct
14 Correct 177 ms 43116 KB Output is correct
15 Correct 183 ms 43556 KB Output is correct
16 Correct 138 ms 31212 KB Output is correct
17 Correct 114 ms 27116 KB Output is correct
18 Correct 48 ms 15724 KB Output is correct
19 Correct 180 ms 43116 KB Output is correct
20 Correct 183 ms 43756 KB Output is correct
21 Correct 136 ms 31192 KB Output is correct
22 Correct 118 ms 27116 KB Output is correct
23 Correct 215 ms 47340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5356 KB Output is correct
3 Correct 4 ms 5356 KB Output is correct
4 Correct 4 ms 5100 KB Output is correct
5 Correct 4 ms 5100 KB Output is correct
6 Correct 4 ms 5356 KB Output is correct
7 Correct 4 ms 5100 KB Output is correct
8 Correct 4 ms 5356 KB Output is correct
9 Correct 6 ms 5356 KB Output is correct
10 Correct 4 ms 5100 KB Output is correct
11 Correct 26 ms 11372 KB Output is correct
12 Correct 51 ms 15724 KB Output is correct
13 Correct 127 ms 29036 KB Output is correct
14 Correct 177 ms 43116 KB Output is correct
15 Correct 183 ms 43556 KB Output is correct
16 Correct 138 ms 31212 KB Output is correct
17 Correct 114 ms 27116 KB Output is correct
18 Correct 48 ms 15724 KB Output is correct
19 Correct 180 ms 43116 KB Output is correct
20 Correct 183 ms 43756 KB Output is correct
21 Correct 136 ms 31192 KB Output is correct
22 Correct 118 ms 27116 KB Output is correct
23 Correct 215 ms 47340 KB Output is correct
24 Correct 14 ms 5100 KB Output is correct
25 Correct 4282 ms 11500 KB Output is correct
26 Execution timed out 5061 ms 15852 KB Time limit exceeded
27 Halted 0 ms 0 KB -