Submission #709342

# Submission time Handle Problem Language Result Execution time Memory
709342 2023-03-13T12:27:04 Z Antekb Amusement Park (JOI17_amusement_park) C++17
82 / 100
39 ms 5808 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], dp[NN];
vector<pii> todo;
int pp;
int dfs2(int v){
    dp[v]=0;
    vis[v]=2;
    for(int u:E[v]){
        if(czy[u] && vis[u]!=2){
            dp[v]=max(dp[v], dfs2(u));
        }
    }
    for(int &u:E[v]){
        if(czy[u] && vis[u]!=2 && dp[u]==dp[v]){
            swap(u, E[v].back());
        }
    }
    dp[v]++;
    todo.eb(-dp[v], v);
    return dp[v];
}
void move(int x){
    int t=Move(x);
    bit[kol[x]]=t;
}
void dfs3(int v, int b){
    deb(v, kol[v]);
    vis[v]=2;
    for(int u:E[v]){
        if(vis[u]==3){
            move(u);
            dfs3(u, b&&(u==E[v].back()));
            if(!(b&&(u==E[v].back())))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, 1);
            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 1036 KB Output is correct
2 Correct 3 ms 1172 KB Output is correct
3 Correct 2 ms 1288 KB Output is correct
4 Correct 2 ms 1164 KB Output is correct
5 Correct 2 ms 1292 KB Output is correct
6 Correct 2 ms 1156 KB Output is correct
7 Correct 2 ms 1288 KB Output is correct
8 Correct 2 ms 1288 KB Output is correct
9 Correct 2 ms 1296 KB Output is correct
10 Correct 3 ms 1024 KB Output is correct
11 Correct 5 ms 1608 KB Output is correct
12 Correct 2 ms 1024 KB Output is correct
13 Correct 2 ms 1168 KB Output is correct
14 Correct 3 ms 1288 KB Output is correct
15 Correct 2 ms 1296 KB Output is correct
16 Correct 2 ms 1304 KB Output is correct
17 Correct 2 ms 1288 KB Output is correct
18 Correct 3 ms 1296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 5604 KB Output is correct
2 Correct 34 ms 5640 KB Output is correct
3 Correct 30 ms 5648 KB Output is correct
4 Correct 18 ms 3108 KB Output is correct
5 Correct 20 ms 4244 KB Output is correct
6 Correct 19 ms 3876 KB Output is correct
7 Correct 19 ms 4004 KB Output is correct
8 Correct 23 ms 4064 KB Output is correct
9 Correct 20 ms 4136 KB Output is correct
10 Correct 14 ms 3628 KB Output is correct
11 Correct 15 ms 3568 KB Output is correct
12 Correct 14 ms 2792 KB Output is correct
13 Correct 15 ms 2836 KB Output is correct
14 Correct 19 ms 2968 KB Output is correct
15 Correct 18 ms 3548 KB Output is correct
16 Correct 20 ms 3516 KB Output is correct
17 Correct 17 ms 3072 KB Output is correct
18 Correct 18 ms 3188 KB Output is correct
19 Correct 18 ms 3104 KB Output is correct
20 Correct 15 ms 4648 KB Output is correct
21 Correct 16 ms 4652 KB Output is correct
22 Correct 20 ms 3748 KB Output is correct
23 Correct 20 ms 4144 KB Output is correct
24 Correct 24 ms 3816 KB Output is correct
25 Correct 20 ms 4092 KB Output is correct
26 Correct 23 ms 4300 KB Output is correct
27 Correct 19 ms 4244 KB Output is correct
28 Correct 20 ms 4388 KB Output is correct
29 Correct 17 ms 3944 KB Output is correct
30 Correct 19 ms 4100 KB Output is correct
31 Correct 2 ms 1356 KB Output is correct
32 Correct 2 ms 1292 KB Output is correct
33 Correct 2 ms 1296 KB Output is correct
34 Correct 2 ms 1156 KB Output is correct
35 Correct 2 ms 1156 KB Output is correct
36 Correct 2 ms 1036 KB Output is correct
37 Correct 2 ms 1024 KB Output is correct
38 Correct 2 ms 1028 KB Output is correct
39 Correct 2 ms 1032 KB Output is correct
40 Correct 2 ms 1156 KB Output is correct
41 Correct 2 ms 1284 KB Output is correct
42 Correct 2 ms 1036 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 2 ms 1236 KB Output is correct
4 Correct 4 ms 1836 KB Output is correct
5 Correct 5 ms 1844 KB Output is correct
6 Correct 4 ms 1836 KB Output is correct
7 Correct 5 ms 1844 KB Output is correct
8 Correct 4 ms 1836 KB Output is correct
9 Correct 20 ms 5808 KB Output is correct
10 Correct 18 ms 5780 KB Output is correct
11 Correct 18 ms 5796 KB Output is correct
12 Correct 2 ms 1028 KB Output is correct
13 Correct 3 ms 1156 KB Output is correct
14 Correct 2 ms 1028 KB Output is correct
15 Correct 2 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 5628 KB Output is correct
2 Correct 28 ms 5608 KB Output is correct
3 Correct 30 ms 5644 KB Output is correct
4 Correct 16 ms 3160 KB Output is correct
5 Correct 23 ms 5032 KB Output is correct
6 Correct 19 ms 4076 KB Output is correct
7 Correct 20 ms 4156 KB Output is correct
8 Correct 19 ms 3620 KB Output is correct
9 Correct 19 ms 3900 KB Output is correct
10 Correct 15 ms 3588 KB Output is correct
11 Correct 15 ms 3652 KB Output is correct
12 Correct 15 ms 2872 KB Output is correct
13 Correct 17 ms 2896 KB Output is correct
14 Correct 19 ms 2976 KB Output is correct
15 Partially correct 25 ms 3464 KB Partially correct
16 Correct 18 ms 3480 KB Output is correct
17 Correct 18 ms 3084 KB Output is correct
18 Partially correct 19 ms 3092 KB Partially correct
19 Correct 19 ms 3108 KB Output is correct
20 Correct 18 ms 4644 KB Output is correct
21 Correct 20 ms 4664 KB Output is correct
22 Correct 20 ms 4140 KB Output is correct
23 Correct 24 ms 4012 KB Output is correct
24 Correct 20 ms 4012 KB Output is correct
25 Correct 19 ms 4232 KB Output is correct
26 Correct 20 ms 4188 KB Output is correct
27 Correct 23 ms 4528 KB Output is correct
28 Correct 19 ms 3844 KB Output is correct
29 Correct 19 ms 3844 KB Output is correct
30 Correct 23 ms 4116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 5564 KB Output is correct
2 Correct 34 ms 5648 KB Output is correct
3 Correct 32 ms 5708 KB Output is correct
4 Correct 18 ms 3104 KB Output is correct
5 Correct 24 ms 5340 KB Output is correct
6 Correct 22 ms 3836 KB Output is correct
7 Correct 19 ms 3852 KB Output is correct
8 Correct 20 ms 4124 KB Output is correct
9 Correct 20 ms 4008 KB Output is correct
10 Correct 17 ms 3532 KB Output is correct
11 Correct 17 ms 3572 KB Output is correct
12 Correct 17 ms 2960 KB Output is correct
13 Correct 16 ms 2804 KB Output is correct
14 Correct 19 ms 2936 KB Output is correct
15 Correct 19 ms 3376 KB Output is correct
16 Correct 20 ms 3536 KB Output is correct
17 Correct 19 ms 3116 KB Output is correct
18 Incorrect 18 ms 3116 KB Output isn't correct
19 Halted 0 ms 0 KB -