Submission #933695

# Submission time Handle Problem Language Result Execution time Memory
933695 2024-02-26T06:39:10 Z parlimoos Amusement Park (JOI17_amusement_park) C++14
8 / 100
20 ms 5652 KB
//‌Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Joi.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

vector<int> jg[10000] , jtr[10000];
int jh[10000] , jtms[10000] , cjh[10000];
int mxj[1000];
bool jms[10000];

int jtimer = -1;
void jdfs1(int v = 0 , int p = -1){
    jh[v] = 1 , jms[v] = 1;
    if(p != -1) cjh[v] = cjh[p] + 1;
    for(int u : jg[v]){
        if(jms[u]) continue;
        jtr[v].pb(u);
        jdfs1(u , v) , jh[v] = max(jh[v] , jh[u] + 1);
    }
}
void jdfs2(int v = 0){
    jtms[v] = ++jtimer , mxj[v] = -1;
    for(int u : jtr[v]) if(mxj[v] == -1 or jh[mxj[v]] < jh[u]) mxj[v] = u;
    if(mxj[v] == -1) return;
    jdfs2(mxj[v]);
    for(int u : jtr[v]) if(u != mxj[v]) jdfs2(u);
}
void Joi(int N , int M , int A[] , int B[] , ll X , int T){
    for(int i = 0 ; i < M ; i++) jg[A[i]].pb(B[i]) , jg[B[i]].pb(A[i]);
    jdfs1() , jdfs2();
    if(jh[0] >= 60){
        ll o = 0;
        for(int i = 0 ; i < N ; i++) MessageBoard(i , int((X >> (cjh[i] % 60)) & 1ll));
    }else for(int i = 0 ; i < N ; i++) MessageBoard(i , int((X >> (jtms[i] % 60)) & 1ll));
}
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Ioi.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

int n;
vector<int> g[10000] , tr[10000];
int h[10000] , tms[10000] , ps[10000];
int ch[10000] , mxi[10000];
bool ms[10000];
ll o = 0;

int timer = -1;
void dfs1(int v = 0 , int p = -1){
    ms[v] = 1 , h[v] = 1 , ps[v] = p;
    if(p != -1) ch[v] = ch[p] + 1;
    for(int u : g[v]){
        if(ms[u]) continue;
        tr[v].pb(u);
        dfs1(u , v) , h[v] = max(h[v] , h[u] + 1);
    }
}
void dfs2(int v = 0){
    tms[v] = ++timer , mxi[v] = -1;
    for(int u : tr[v]) if(mxi[v] == -1 or h[mxi[v]] < h[u]) mxi[v] = u;
    if(mxi[v] == -1) return;
    dfs2(mxi[v]);
    for(int u : tr[v]) if(mxi[v] != u) dfs2(u);
}
void dfs3(int v , bool bb){
    for(int u : tr[v]){
        if(bb){
            if(u != mxi[v] and tms[u] < 60){
                ll d = Move(u);
                o |= (d << tms[u]);
                dfs3(u , 0);
                d = Move(v);
            }
        }else{
            if(tms[u] < 60){
                ll d = Move(u);
                o |= (d << tms[u]);
                dfs3(u , 0);
                d = Move(v);
            }
        }
    }
}
ll Ioi(int N , int M , int A[] , int B[] , int P , int V , int T){
    n = N;
    for(int i = 0 ; i < M ; i++) g[A[i]].pb(B[i]) , g[B[i]].pb(A[i]);
    dfs1() , dfs2();
    if(h[0] >= 60){
        if(ch[P] < 59){
            ll d = V;
            while(P != 0) d = Move(ps[P]) , P = ps[P];
            o = d;
            int i;
            for(i = 1 ; i < 60 ; i++){
                d = Move(mxi[P]) , P = mxi[P];
                o |= (d << i);
            }
            if(i < 60) Move(70);
        }else{
            o |= (V << (ch[P] % 60));
            ll d = V;
            for(int i = 1 ; i < 60 ; i++){
                d = Move(ps[P]) , P = ps[P];
                o |= (d << (ch[P] % 60));
            }
        }
        return o;
    }
    ll d = V;
    while(P != 0) d = Move(ps[P]) , P = ps[P];
    o = d;
    while(true){
        dfs3(P , 1);
        if(mxi[P] == -1) break;
        d = Move(mxi[P]) , P = mxi[P];
        o |= (d << tms[P]);
    }
    return o;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, ll, int)':
Joi.cpp:44:12: warning: unused variable 'o' [-Wunused-variable]
   44 |         ll o = 0;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1808 KB Output is correct
2 Correct 1 ms 1812 KB Output is correct
3 Correct 2 ms 1824 KB Output is correct
4 Correct 1 ms 1808 KB Output is correct
5 Correct 1 ms 1812 KB Output is correct
6 Correct 2 ms 1812 KB Output is correct
7 Correct 2 ms 1820 KB Output is correct
8 Correct 2 ms 1820 KB Output is correct
9 Correct 2 ms 1820 KB Output is correct
10 Correct 1 ms 1816 KB Output is correct
11 Correct 3 ms 2144 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
13 Correct 1 ms 1820 KB Output is correct
14 Correct 2 ms 1828 KB Output is correct
15 Correct 2 ms 1828 KB Output is correct
16 Correct 1 ms 1828 KB Output is correct
17 Correct 1 ms 1820 KB Output is correct
18 Correct 1 ms 1820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 5476 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1820 KB Output is correct
2 Correct 1 ms 1828 KB Output is correct
3 Correct 1 ms 1812 KB Output is correct
4 Incorrect 4 ms 2372 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 5652 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 5468 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -