Submission #133864

# Submission time Handle Problem Language Result Execution time Memory
133864 2019-07-21T15:26:41 Z doowey Amusement Park (JOI17_amusement_park) C++14
82 / 100
71 ms 6792 KB
#include <bits/stdc++.h>
#include "Joi.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

void send(int idx, int bit){
    MessageBoard(idx, bit);
}

const int N = (int)1e4 + 3;
const int LOG = 60;

vector<int> T[N];

int tin[N]; // modulo LOG
int cnt;

void dfs(int u){
    if(tin[u] != -1){
        return;
    }
    tin[u] = cnt ++ ;
    cnt %= LOG;
    for(auto p : T[u]){
        dfs(p);
    }
}

void Joi(int n, int m, int A[], int B[], ll X, int useless) {
    for(int i = 0 ; i < n; i ++ )
        tin[i] = -1;
    for(int i = 0 ; i < m ; i ++ ){
        T[A[i]].push_back(B[i]);
        T[B[i]].push_back(A[i]);
    }
    dfs(0);
    for(int i = 0 ; i < n; i ++ ){
        if(X & (1ll << tin[i])){
            send(i, 1);
        }
        else{
            send(i, 0);
        }
    }
}
#include <bits/stdc++.h>
#include "Ioi.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

const int MAXN = (int)1e4 + 9;
const int LG = 60;

vector<int> TT[MAXN];
int ti[MAXN];
int cn;

void gt(int u){
    if(ti[u] != -1) return;
    ti[u] = cn ++ ;
    cn %= LG;
    for(auto p : TT[u]){
        gt(p);
    }
}

int pv[LG][MAXN];

set<int> rem;

int match[LG];

ll Ioi(int n, int m, int a[], int b[], int p, int v, int useless) {
   for(int i = 0 ; i < m ; i ++ ){
        TT[a[i]].push_back(b[i]);
        TT[b[i]].push_back(a[i]);
    }
    for(int i = 0 ; i < n ; i ++ )
        ti[i] = -1;
    gt(0);
    int node;
    for(int i = 0 ; i < LG; i ++ ) {
        for(int j = 0 ; j < n; j ++ )
            pv[i][j] = -1;
        queue<int> ff;
        for(int j = 0 ; j < n; j ++){
            if(ti[j] == i){
                pv[i][j] = j;
                ff.push(j);
            }
        }
        while(!ff.empty()){
            node = ff.front();
            ff.pop();
            for(auto p : TT[node]){
                if(pv[i][p] == -1){
                    pv[i][p] = node;
                    ff.push(p);
                }
            }
        }
    }
    for(int i = 0 ; i < LG; i ++ )
        rem.insert(i);
    rem.erase(ti[p]);
    match[ti[p]] = v;
    int go;
    int bit;
    while(!rem.empty()){
        go = *rem.begin();
        do{
            bit = Move(pv[go][p]);
            p = pv[go][p];  
            if(rem.count(ti[p])){
                rem.erase(ti[p]);
                match[ti[p]] = bit;
            }
        }while(pv[go][p] != p);
    }
    ll ret = 0;
    for(int i = 0 ; i < LG; i ++ )
        ret += match[i] * (1ll << i);
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1396 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 5 ms 1788 KB Output is correct
4 Correct 4 ms 1752 KB Output is correct
5 Correct 4 ms 1660 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 6 ms 1664 KB Output is correct
8 Correct 5 ms 1796 KB Output is correct
9 Correct 5 ms 1660 KB Output is correct
10 Correct 5 ms 1628 KB Output is correct
11 Correct 10 ms 1864 KB Output is correct
12 Correct 4 ms 1532 KB Output is correct
13 Correct 5 ms 1660 KB Output is correct
14 Correct 6 ms 1744 KB Output is correct
15 Correct 5 ms 1668 KB Output is correct
16 Correct 5 ms 1536 KB Output is correct
17 Correct 6 ms 1796 KB Output is correct
18 Correct 5 ms 1640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 6528 KB Output is correct
2 Correct 66 ms 6536 KB Output is correct
3 Correct 67 ms 6684 KB Output is correct
4 Correct 51 ms 5272 KB Output is correct
5 Correct 54 ms 5664 KB Output is correct
6 Correct 52 ms 5496 KB Output is correct
7 Correct 53 ms 5528 KB Output is correct
8 Correct 52 ms 5660 KB Output is correct
9 Correct 51 ms 5572 KB Output is correct
10 Correct 31 ms 5392 KB Output is correct
11 Correct 31 ms 5276 KB Output is correct
12 Correct 41 ms 5120 KB Output is correct
13 Correct 41 ms 5128 KB Output is correct
14 Correct 43 ms 5292 KB Output is correct
15 Correct 53 ms 5272 KB Output is correct
16 Correct 53 ms 5272 KB Output is correct
17 Correct 50 ms 5332 KB Output is correct
18 Correct 48 ms 5324 KB Output is correct
19 Correct 50 ms 5272 KB Output is correct
20 Correct 34 ms 5528 KB Output is correct
21 Correct 34 ms 5600 KB Output is correct
22 Correct 47 ms 5532 KB Output is correct
23 Correct 46 ms 5528 KB Output is correct
24 Correct 46 ms 5536 KB Output is correct
25 Correct 46 ms 5400 KB Output is correct
26 Correct 48 ms 5496 KB Output is correct
27 Correct 46 ms 5528 KB Output is correct
28 Correct 46 ms 5664 KB Output is correct
29 Correct 42 ms 5384 KB Output is correct
30 Correct 43 ms 5388 KB Output is correct
31 Correct 5 ms 1752 KB Output is correct
32 Correct 5 ms 1524 KB Output is correct
33 Correct 5 ms 1740 KB Output is correct
34 Correct 5 ms 1756 KB Output is correct
35 Correct 4 ms 1528 KB Output is correct
36 Correct 4 ms 1524 KB Output is correct
37 Correct 4 ms 1532 KB Output is correct
38 Correct 4 ms 1752 KB Output is correct
39 Correct 4 ms 1532 KB Output is correct
40 Correct 4 ms 1524 KB Output is correct
41 Correct 4 ms 1532 KB Output is correct
42 Correct 4 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1396 KB Output is correct
2 Correct 4 ms 1524 KB Output is correct
3 Correct 4 ms 1524 KB Output is correct
4 Correct 8 ms 2284 KB Output is correct
5 Correct 9 ms 2208 KB Output is correct
6 Correct 10 ms 2336 KB Output is correct
7 Correct 9 ms 2196 KB Output is correct
8 Correct 8 ms 2208 KB Output is correct
9 Correct 39 ms 5784 KB Output is correct
10 Correct 40 ms 6032 KB Output is correct
11 Correct 39 ms 5784 KB Output is correct
12 Correct 4 ms 1396 KB Output is correct
13 Correct 4 ms 1532 KB Output is correct
14 Correct 16 ms 1660 KB Output is correct
15 Correct 6 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 6708 KB Output is correct
2 Correct 68 ms 6532 KB Output is correct
3 Correct 68 ms 6792 KB Output is correct
4 Correct 47 ms 5400 KB Output is correct
5 Partially correct 56 ms 5784 KB Partially correct
6 Correct 52 ms 5400 KB Output is correct
7 Correct 52 ms 5536 KB Output is correct
8 Correct 50 ms 5500 KB Output is correct
9 Correct 52 ms 5636 KB Output is correct
10 Correct 32 ms 5404 KB Output is correct
11 Correct 31 ms 5412 KB Output is correct
12 Correct 41 ms 4992 KB Output is correct
13 Correct 42 ms 5120 KB Output is correct
14 Partially correct 42 ms 5324 KB Partially correct
15 Correct 53 ms 5432 KB Output is correct
16 Correct 53 ms 5280 KB Output is correct
17 Correct 52 ms 5272 KB Output is correct
18 Correct 50 ms 5280 KB Output is correct
19 Correct 49 ms 5296 KB Output is correct
20 Correct 34 ms 5540 KB Output is correct
21 Correct 34 ms 5716 KB Output is correct
22 Correct 46 ms 5656 KB Output is correct
23 Correct 46 ms 5604 KB Output is correct
24 Correct 46 ms 5484 KB Output is correct
25 Correct 47 ms 5656 KB Output is correct
26 Correct 46 ms 5400 KB Output is correct
27 Correct 46 ms 5688 KB Output is correct
28 Correct 45 ms 5532 KB Output is correct
29 Correct 41 ms 5416 KB Output is correct
30 Correct 44 ms 5456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 6632 KB Output is correct
2 Correct 67 ms 6740 KB Output is correct
3 Correct 71 ms 6668 KB Output is correct
4 Correct 49 ms 5332 KB Output is correct
5 Incorrect 55 ms 5792 KB Output isn't correct
6 Halted 0 ms 0 KB -