Submission #709341

# Submission time Handle Problem Language Result Execution time Memory
709341 2023-03-13T12:19:01 Z Antekb Amusement Park (JOI17_amusement_park) C++17
82 / 100
38 ms 5700 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
void debug2(){cerr<<"\n";}
template<typename H, typename... T>
void debug2(H h, T... t){
  cerr<<h;
  if(sizeof...(t))cerr<<", ";
  debug2(t...);
}
#define deb(x) cerr<<#x<<" = ";debug2(x);
mt19937 rng2(chrono::high_resolution_clock().now().time_since_epoch().count());
const int NN2=1e4+5;
#include "Joi.h"

vector<int> bit2;
vi E2[NN2];
int reszta2;
int vis2[NN2], czy2[NN2], kol2[NN2];
vector<pii> todo2;
int ddfs2(int v){
    int m=0;
    vis2[v]=2;
    for(int u:E2[v]){
        if(czy2[u] && vis2[u]!=2){
            m=max(m, ddfs2(u));
        }
    }
    m++;
    todo2.eb(-m, v);
    return m;
}
vi ddfs(int v){
    vi V;
    vis2[v]=1;
    for(int u:E2[v]){
        if(!vis2[u]){
            vi V2=ddfs(u);
            for(int i:V2)V.pb(i);
        }
    }
    czy2[v]=1;
    V.pb(v);
    if(v==0 || (reszta2-V.size()>=60 && V.size()>=60)){
        for(int i:V)czy2[i]=1;
        ddfs2(v);
        sort(all(todo2));
        for(int i=0; i<60; i++)kol2[todo2[i].nd]=i;
        for(pii i:todo2)czy2[i.nd]=0, vis2[i.nd]=1;
        V.clear();
        reszta2-=todo2.size();
        todo2.clear();
    }
    return V;
}
void Joi(int n, int m, int A[], int B[], long long X, int T) {
    reszta2=n;
    for(int i=0; i<m; i++){
        E2[A[i]].pb(B[i]);
        E2[B[i]].pb(A[i]);
    }
    for(int i=0; i<60; i++)bit2.pb(X&1), X/=2;
    ddfs(0);
    for(int i=0; i<n; i++){
        MessageBoard(i, bit2[kol2[i]]);
    }
}
#include<bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
void debug(){cerr<<"\n";}
template<typename H, typename... T>
void debug(H h, T... t){
  cerr<<h;
  if(sizeof...(t))cerr<<", ";
  debug(t...);
}
#define deb(x...) cerr<<#x<<" = ";debug(x);
mt19937 rng(chrono::high_resolution_clock().now().time_since_epoch().count());
const int NN=1e4+5, INF=1e9+5;
#include "Ioi.h"

int bit[60];
int reszta;
vi E[NN];
int vis[NN], czy[NN], kol[NN], par[NN];
vector<pii> todo;
int pp;
int dfs2(int v){
    int m=0;
    vis[v]=2;
    for(int u:E[v]){
        if(czy[u] && vis[u]!=2){
            m=max(m, dfs2(u));
        }
    }
    m++;
    todo.eb(-m, v);
    return m;
}
void move(int x){
    int t=Move(x);
    bit[kol[x]]=t;
}
void dfs3(int v){
    deb(v, kol[v]);
    vis[v]=2;
    for(int u:E[v]){
        if(vis[u]==3){
            move(u);
            dfs3(u);
            move(v);
        }
    }
}
vector<int> dfs(int v){
    vis[v]=1;
    vi V;
    for(int u:E[v]){
        if(!vis[u]){
            par[u]=v;
            vi V2=dfs(u);
            for(int i:V2)V.pb(i);
        }
    }
    //deb(v, 1);
    if(v==200){
        deb();
        deb();
        deb();
    }
    V.pb(v);
    if(v==0 || (reszta-V.size()>=60 && V.size()>=60)){
        deb(v, V.size());
        for(int i:V)czy[i]=1;
        dfs2(v);
        sort(all(todo));
        for(pii &i:todo){
            if(i.nd==200){
                deb(i.st, i.nd, czy[200], pp)
            }
        }
        for(int i=0; i<60; i++)kol[todo[i].nd]=i, vis[todo[i].nd]=3;
        if(czy[pp]){
            deb(5, v);
            while(vis[pp]!=3){
                deb(pp, par[pp]);
                move(par[pp]), pp=par[pp];
            }
            deb(5);
            dfs3(pp);
            pp=1e4;
        }
        for(pii i:todo)czy[i.nd]=0, vis[i.nd]=1;
        V.clear();
        reszta-=todo.size();
        todo.clear();
    }
    return V;
}
long long Ioi(int n, int m, int A[], int B[], int P, int V, int T) {
    reszta=n;
    for(int i=0; i<m; i++){
        E[A[i]].pb(B[i]);
        E[B[i]].pb(A[i]);
    }
    pp=P;
    dfs(0);
    bit[kol[P]]=V;
    ll x=0;
    for(int i=59; i>=0; i--)x=x+x+bit[i];
        deb(x);
    return x;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1028 KB Output is correct
2 Correct 3 ms 1284 KB Output is correct
3 Correct 2 ms 1288 KB Output is correct
4 Correct 2 ms 1028 KB Output is correct
5 Correct 2 ms 1280 KB Output is correct
6 Correct 2 ms 1032 KB Output is correct
7 Correct 2 ms 1296 KB Output is correct
8 Correct 2 ms 1300 KB Output is correct
9 Correct 2 ms 1288 KB Output is correct
10 Correct 3 ms 1040 KB Output is correct
11 Correct 4 ms 1580 KB Output is correct
12 Correct 2 ms 1028 KB Output is correct
13 Correct 2 ms 1288 KB Output is correct
14 Correct 3 ms 1296 KB Output is correct
15 Correct 2 ms 1288 KB Output is correct
16 Correct 3 ms 1288 KB Output is correct
17 Correct 2 ms 1288 KB Output is correct
18 Correct 2 ms 1288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 5476 KB Output is correct
2 Correct 34 ms 5472 KB Output is correct
3 Correct 35 ms 5480 KB Output is correct
4 Correct 18 ms 3088 KB Output is correct
5 Correct 23 ms 4344 KB Output is correct
6 Correct 20 ms 3844 KB Output is correct
7 Correct 19 ms 3860 KB Output is correct
8 Correct 19 ms 4152 KB Output is correct
9 Correct 20 ms 4112 KB Output is correct
10 Correct 17 ms 3560 KB Output is correct
11 Correct 19 ms 3504 KB Output is correct
12 Correct 18 ms 2752 KB Output is correct
13 Correct 16 ms 2788 KB Output is correct
14 Correct 16 ms 2832 KB Output is correct
15 Correct 19 ms 3304 KB Output is correct
16 Correct 19 ms 3488 KB Output is correct
17 Correct 18 ms 3136 KB Output is correct
18 Correct 19 ms 3100 KB Output is correct
19 Correct 22 ms 3012 KB Output is correct
20 Correct 18 ms 4552 KB Output is correct
21 Correct 19 ms 4604 KB Output is correct
22 Correct 19 ms 3748 KB Output is correct
23 Correct 20 ms 4152 KB Output is correct
24 Correct 22 ms 3984 KB Output is correct
25 Correct 20 ms 4100 KB Output is correct
26 Correct 19 ms 4232 KB Output is correct
27 Correct 19 ms 4116 KB Output is correct
28 Correct 20 ms 4320 KB Output is correct
29 Correct 18 ms 3852 KB Output is correct
30 Correct 19 ms 3820 KB Output is correct
31 Correct 2 ms 1028 KB Output is correct
32 Correct 2 ms 1156 KB Output is correct
33 Correct 2 ms 1288 KB Output is correct
34 Correct 2 ms 1036 KB Output is correct
35 Correct 2 ms 1292 KB Output is correct
36 Correct 2 ms 1036 KB Output is correct
37 Correct 3 ms 1028 KB Output is correct
38 Correct 2 ms 1036 KB Output is correct
39 Correct 2 ms 1120 KB Output is correct
40 Correct 2 ms 1156 KB Output is correct
41 Correct 2 ms 1284 KB Output is correct
42 Correct 4 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1292 KB Output is correct
2 Correct 2 ms 1284 KB Output is correct
3 Correct 3 ms 1240 KB Output is correct
4 Correct 5 ms 1836 KB Output is correct
5 Correct 6 ms 1844 KB Output is correct
6 Correct 7 ms 1832 KB Output is correct
7 Correct 6 ms 1836 KB Output is correct
8 Correct 5 ms 1840 KB Output is correct
9 Correct 19 ms 5700 KB Output is correct
10 Correct 22 ms 5600 KB Output is correct
11 Correct 19 ms 5680 KB Output is correct
12 Correct 2 ms 1080 KB Output is correct
13 Correct 2 ms 1036 KB Output is correct
14 Correct 3 ms 1028 KB Output is correct
15 Correct 2 ms 1036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 5600 KB Output is correct
2 Correct 30 ms 5624 KB Output is correct
3 Correct 28 ms 5540 KB Output is correct
4 Correct 19 ms 3108 KB Output is correct
5 Correct 23 ms 5008 KB Output is correct
6 Correct 31 ms 4100 KB Output is correct
7 Correct 20 ms 4136 KB Output is correct
8 Correct 22 ms 3744 KB Output is correct
9 Correct 22 ms 3864 KB Output is correct
10 Correct 17 ms 3636 KB Output is correct
11 Correct 15 ms 3616 KB Output is correct
12 Correct 18 ms 2832 KB Output is correct
13 Correct 18 ms 2884 KB Output is correct
14 Correct 19 ms 3036 KB Output is correct
15 Partially correct 19 ms 3508 KB Partially correct
16 Correct 17 ms 3316 KB Output is correct
17 Correct 18 ms 3072 KB Output is correct
18 Partially correct 16 ms 3124 KB Partially correct
19 Correct 17 ms 3100 KB Output is correct
20 Correct 16 ms 4652 KB Output is correct
21 Correct 15 ms 4672 KB Output is correct
22 Correct 20 ms 4084 KB Output is correct
23 Correct 20 ms 3856 KB Output is correct
24 Correct 20 ms 3964 KB Output is correct
25 Correct 20 ms 4180 KB Output is correct
26 Correct 19 ms 4128 KB Output is correct
27 Correct 20 ms 4396 KB Output is correct
28 Correct 20 ms 3864 KB Output is correct
29 Correct 23 ms 3776 KB Output is correct
30 Correct 20 ms 4120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5632 KB Output is correct
2 Correct 34 ms 5672 KB Output is correct
3 Correct 31 ms 5564 KB Output is correct
4 Correct 17 ms 3112 KB Output is correct
5 Correct 22 ms 5416 KB Output is correct
6 Correct 19 ms 3860 KB Output is correct
7 Correct 25 ms 3600 KB Output is correct
8 Correct 20 ms 4128 KB Output is correct
9 Correct 19 ms 3880 KB Output is correct
10 Correct 15 ms 3628 KB Output is correct
11 Correct 16 ms 3532 KB Output is correct
12 Correct 16 ms 2816 KB Output is correct
13 Correct 18 ms 2780 KB Output is correct
14 Correct 19 ms 2836 KB Output is correct
15 Correct 17 ms 3384 KB Output is correct
16 Correct 18 ms 3544 KB Output is correct
17 Correct 17 ms 3104 KB Output is correct
18 Incorrect 17 ms 3112 KB Output isn't correct
19 Halted 0 ms 0 KB -