Submission #63478

# Submission time Handle Problem Language Result Execution time Memory
63478 2018-08-01T22:48:26 Z reality Amusement Park (JOI17_amusement_park) C++17
28 / 100
119 ms 59136 KB
#include "Joi.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;

static vi Euler;

static int was[N];

static int ok[N];

static vi g[N];

static int T = -1;

static void dfs(int node,int prev) {
    T = (T + 1) % 60;
    ok[Euler.size()] = T;
    Euler.pb(node);
    for (auto it : g[node])
        if (it != prev) {
            dfs(it,node);
            Euler.pb(node);
        }
}

static int f[N];

static int get(int k) {
    return k == f[k] ? k : f[k] = get(f[k]);
}

static int n;

void Joi(int N, int M, int A[], int B[], long long X, int T) {
    srand(696969);
    memset(ok,-1,sizeof(ok));
  	n = N;
    for (int i = 0;i < n;++i)
  		f[i] = i;
  	for (int i = 0;i < M;++i) {
  		if (get(A[i]) == get(B[i]))
  			continue;
  		g[A[i]].pb(B[i]);
  		g[B[i]].pb(A[i]);
  		f[get(A[i])] = get(B[i]);
  	}
  	dfs(35,-1);
  	int sz = Euler.size();
    assert(sz <= 2 * n);
    for (int i = 0;i < sz;++i)
  		if (ok[i] != -1)
  			MessageBoard(Euler[i],(X >> ok[i]) & 1);
}
#include "Ioi.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;

static vi Euler;

static int was[N];

static int ok[N];

static int W[N];

static vi g[N];

static int T = -1;

static void dfs(int node,int prev) {
	T = (T + 1) % 60;
    ok[Euler.size()] = T;
    W[node] = T;
    Euler.pb(node);
    for (auto it : g[node])
        if (it != prev) {
            dfs(it,node);
            Euler.pb(node);
        }
}

static int f[N];

static int get(int k) {
	return k == f[k] ? k : f[k] = get(f[k]);
}

static int n;

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  	srand(696969);
  	memset(ok,-1,sizeof(ok));
  	n = N;
  	for (int i = 0;i < n;++i)
  		f[i] = i;
  	for (int i = 0;i < M;++i) {
  		if (get(A[i]) == get(B[i]))
  			continue;
  		g[A[i]].pb(B[i]);
  		g[B[i]].pb(A[i]);
  		f[get(A[i])] = get(B[i]);
  	}
  	dfs(35,-1);
  	int sz = Euler.size();
  	ll mask = (1ll << 60) - 1;
  	int pos = -1;
  	for (int i = 0;i < sz;++i)
  		if (Euler[i] == P) {
  			pos = i;
  			break;
  		}
  	ll answer = 0;
  	answer |= V * (1ll << W[Euler[pos]]);
  	mask ^= (1ll << W[Euler[pos]]);
  	int called = 0;
  	for (int i = (pos + 1) % sz,j = pos;mask;i = (i + 1) % sz,j = (j + 1) % sz)  {
  		if (Euler[i] == Euler[j])
  			continue;
  		int nxt = Move(Euler[i]);
  		++called;
  		//assert(called <= 300);
  		if (mask & (1ll << W[Euler[i]])) {
  			mask ^= 1ll << W[Euler[i]];
  			answer |= nxt * (1ll << W[Euler[i]]); 
  		}
  	}
  	return answer;
}

Compilation message

Joi.cpp:22:12: warning: 'was' defined but not used [-Wunused-variable]
 static int was[N];
            ^~~

Ioi.cpp:22:12: warning: 'was' defined but not used [-Wunused-variable]
 static int was[N];
            ^~~
# Verdict Execution time Memory Grader output
1 Correct 54 ms 55612 KB Output is correct
2 Correct 49 ms 55792 KB Output is correct
3 Correct 59 ms 55896 KB Output is correct
4 Correct 48 ms 55908 KB Output is correct
5 Correct 49 ms 56096 KB Output is correct
6 Correct 51 ms 56272 KB Output is correct
7 Correct 49 ms 56272 KB Output is correct
8 Correct 54 ms 56272 KB Output is correct
9 Correct 62 ms 56272 KB Output is correct
10 Correct 51 ms 56272 KB Output is correct
11 Correct 67 ms 56416 KB Output is correct
12 Correct 48 ms 56416 KB Output is correct
13 Correct 57 ms 56416 KB Output is correct
14 Correct 50 ms 56416 KB Output is correct
15 Correct 48 ms 56416 KB Output is correct
16 Correct 53 ms 56416 KB Output is correct
17 Correct 56 ms 56416 KB Output is correct
18 Correct 53 ms 56416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 58856 KB Output is correct
2 Correct 94 ms 58888 KB Output is correct
3 Correct 93 ms 58888 KB Output is correct
4 Correct 78 ms 58888 KB Output is correct
5 Correct 71 ms 58888 KB Output is correct
6 Correct 73 ms 58888 KB Output is correct
7 Correct 74 ms 58888 KB Output is correct
8 Correct 75 ms 58888 KB Output is correct
9 Correct 67 ms 58888 KB Output is correct
10 Correct 68 ms 58888 KB Output is correct
11 Correct 70 ms 58888 KB Output is correct
12 Correct 76 ms 58888 KB Output is correct
13 Correct 68 ms 58888 KB Output is correct
14 Correct 77 ms 58888 KB Output is correct
15 Correct 76 ms 58888 KB Output is correct
16 Correct 86 ms 58888 KB Output is correct
17 Correct 79 ms 58888 KB Output is correct
18 Correct 65 ms 58888 KB Output is correct
19 Correct 70 ms 58888 KB Output is correct
20 Correct 61 ms 58888 KB Output is correct
21 Correct 61 ms 58888 KB Output is correct
22 Correct 69 ms 58888 KB Output is correct
23 Correct 75 ms 58888 KB Output is correct
24 Correct 66 ms 58888 KB Output is correct
25 Correct 87 ms 58888 KB Output is correct
26 Correct 81 ms 58888 KB Output is correct
27 Correct 91 ms 58888 KB Output is correct
28 Correct 99 ms 58888 KB Output is correct
29 Correct 100 ms 58888 KB Output is correct
30 Correct 70 ms 58888 KB Output is correct
31 Correct 59 ms 58888 KB Output is correct
32 Correct 50 ms 58888 KB Output is correct
33 Correct 55 ms 58888 KB Output is correct
34 Correct 64 ms 58888 KB Output is correct
35 Correct 60 ms 58888 KB Output is correct
36 Correct 56 ms 58888 KB Output is correct
37 Correct 49 ms 58888 KB Output is correct
38 Correct 58 ms 58888 KB Output is correct
39 Correct 61 ms 58888 KB Output is correct
40 Correct 57 ms 58888 KB Output is correct
41 Correct 59 ms 58888 KB Output is correct
42 Correct 60 ms 58888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 58888 KB Output is correct
2 Correct 59 ms 58888 KB Output is correct
3 Correct 61 ms 58888 KB Output is correct
4 Correct 60 ms 58888 KB Output is correct
5 Correct 61 ms 58888 KB Output is correct
6 Correct 62 ms 58888 KB Output is correct
7 Correct 61 ms 58888 KB Output is correct
8 Correct 61 ms 58888 KB Output is correct
9 Correct 67 ms 59008 KB Output is correct
10 Correct 62 ms 59072 KB Output is correct
11 Correct 59 ms 59136 KB Output is correct
12 Correct 51 ms 59136 KB Output is correct
13 Correct 48 ms 59136 KB Output is correct
14 Correct 50 ms 59136 KB Output is correct
15 Correct 57 ms 59136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 59136 KB Output is correct
2 Correct 93 ms 59136 KB Output is correct
3 Correct 90 ms 59136 KB Output is correct
4 Correct 79 ms 59136 KB Output is correct
5 Partially correct 81 ms 59136 KB Partially correct
6 Correct 71 ms 59136 KB Output is correct
7 Correct 65 ms 59136 KB Output is correct
8 Correct 66 ms 59136 KB Output is correct
9 Correct 65 ms 59136 KB Output is correct
10 Correct 78 ms 59136 KB Output is correct
11 Correct 76 ms 59136 KB Output is correct
12 Correct 81 ms 59136 KB Output is correct
13 Correct 70 ms 59136 KB Output is correct
14 Correct 74 ms 59136 KB Output is correct
15 Correct 74 ms 59136 KB Output is correct
16 Correct 72 ms 59136 KB Output is correct
17 Correct 84 ms 59136 KB Output is correct
18 Correct 78 ms 59136 KB Output is correct
19 Correct 77 ms 59136 KB Output is correct
20 Incorrect 61 ms 59136 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 59136 KB Output is correct
2 Correct 86 ms 59136 KB Output is correct
3 Correct 76 ms 59136 KB Output is correct
4 Correct 71 ms 59136 KB Output is correct
5 Correct 82 ms 59136 KB Output is correct
6 Correct 74 ms 59136 KB Output is correct
7 Correct 70 ms 59136 KB Output is correct
8 Correct 65 ms 59136 KB Output is correct
9 Correct 73 ms 59136 KB Output is correct
10 Correct 72 ms 59136 KB Output is correct
11 Correct 65 ms 59136 KB Output is correct
12 Correct 72 ms 59136 KB Output is correct
13 Correct 65 ms 59136 KB Output is correct
14 Correct 64 ms 59136 KB Output is correct
15 Correct 64 ms 59136 KB Output is correct
16 Correct 66 ms 59136 KB Output is correct
17 Correct 65 ms 59136 KB Output is correct
18 Correct 68 ms 59136 KB Output is correct
19 Correct 72 ms 59136 KB Output is correct
20 Incorrect 76 ms 59136 KB Output isn't correct
21 Halted 0 ms 0 KB -