#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();
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]]);
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]);
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 |
65 ms |
55740 KB |
Output is correct |
2 |
Correct |
59 ms |
55964 KB |
Output is correct |
3 |
Correct |
52 ms |
55976 KB |
Output is correct |
4 |
Correct |
52 ms |
55976 KB |
Output is correct |
5 |
Correct |
50 ms |
56128 KB |
Output is correct |
6 |
Correct |
54 ms |
56160 KB |
Output is correct |
7 |
Correct |
56 ms |
56312 KB |
Output is correct |
8 |
Correct |
49 ms |
56464 KB |
Output is correct |
9 |
Correct |
60 ms |
56464 KB |
Output is correct |
10 |
Correct |
49 ms |
56464 KB |
Output is correct |
11 |
Correct |
57 ms |
56512 KB |
Output is correct |
12 |
Correct |
56 ms |
56512 KB |
Output is correct |
13 |
Correct |
55 ms |
56512 KB |
Output is correct |
14 |
Correct |
61 ms |
56512 KB |
Output is correct |
15 |
Correct |
57 ms |
56512 KB |
Output is correct |
16 |
Correct |
55 ms |
56512 KB |
Output is correct |
17 |
Correct |
60 ms |
56512 KB |
Output is correct |
18 |
Correct |
59 ms |
56512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
58664 KB |
Output is correct |
2 |
Correct |
84 ms |
58752 KB |
Output is correct |
3 |
Correct |
76 ms |
58768 KB |
Output is correct |
4 |
Correct |
81 ms |
58768 KB |
Output is correct |
5 |
Correct |
83 ms |
58768 KB |
Output is correct |
6 |
Correct |
79 ms |
58768 KB |
Output is correct |
7 |
Correct |
81 ms |
58768 KB |
Output is correct |
8 |
Correct |
77 ms |
58768 KB |
Output is correct |
9 |
Correct |
78 ms |
58768 KB |
Output is correct |
10 |
Correct |
80 ms |
58768 KB |
Output is correct |
11 |
Correct |
79 ms |
58768 KB |
Output is correct |
12 |
Correct |
73 ms |
58768 KB |
Output is correct |
13 |
Correct |
79 ms |
58768 KB |
Output is correct |
14 |
Correct |
73 ms |
58768 KB |
Output is correct |
15 |
Correct |
83 ms |
58768 KB |
Output is correct |
16 |
Correct |
79 ms |
58768 KB |
Output is correct |
17 |
Correct |
82 ms |
58768 KB |
Output is correct |
18 |
Correct |
74 ms |
58768 KB |
Output is correct |
19 |
Correct |
80 ms |
58768 KB |
Output is correct |
20 |
Correct |
80 ms |
58768 KB |
Output is correct |
21 |
Correct |
74 ms |
58768 KB |
Output is correct |
22 |
Correct |
77 ms |
58768 KB |
Output is correct |
23 |
Correct |
94 ms |
58768 KB |
Output is correct |
24 |
Correct |
77 ms |
58768 KB |
Output is correct |
25 |
Correct |
79 ms |
58856 KB |
Output is correct |
26 |
Correct |
69 ms |
58944 KB |
Output is correct |
27 |
Correct |
74 ms |
58944 KB |
Output is correct |
28 |
Correct |
69 ms |
58944 KB |
Output is correct |
29 |
Correct |
67 ms |
58944 KB |
Output is correct |
30 |
Correct |
69 ms |
58944 KB |
Output is correct |
31 |
Correct |
60 ms |
58944 KB |
Output is correct |
32 |
Correct |
61 ms |
58944 KB |
Output is correct |
33 |
Correct |
63 ms |
58944 KB |
Output is correct |
34 |
Correct |
65 ms |
58944 KB |
Output is correct |
35 |
Correct |
61 ms |
58944 KB |
Output is correct |
36 |
Correct |
56 ms |
58944 KB |
Output is correct |
37 |
Correct |
51 ms |
58944 KB |
Output is correct |
38 |
Correct |
51 ms |
58944 KB |
Output is correct |
39 |
Correct |
60 ms |
58944 KB |
Output is correct |
40 |
Correct |
54 ms |
58944 KB |
Output is correct |
41 |
Correct |
55 ms |
58944 KB |
Output is correct |
42 |
Correct |
50 ms |
58944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
58944 KB |
Output is correct |
2 |
Correct |
57 ms |
58944 KB |
Output is correct |
3 |
Correct |
55 ms |
58944 KB |
Output is correct |
4 |
Correct |
59 ms |
58944 KB |
Output is correct |
5 |
Correct |
60 ms |
58944 KB |
Output is correct |
6 |
Correct |
59 ms |
58944 KB |
Output is correct |
7 |
Correct |
52 ms |
58944 KB |
Output is correct |
8 |
Correct |
61 ms |
58944 KB |
Output is correct |
9 |
Correct |
80 ms |
59168 KB |
Output is correct |
10 |
Correct |
67 ms |
59344 KB |
Output is correct |
11 |
Correct |
70 ms |
59344 KB |
Output is correct |
12 |
Correct |
58 ms |
59344 KB |
Output is correct |
13 |
Correct |
55 ms |
59344 KB |
Output is correct |
14 |
Correct |
67 ms |
59344 KB |
Output is correct |
15 |
Correct |
59 ms |
59344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
59344 KB |
Output is correct |
2 |
Correct |
83 ms |
59344 KB |
Output is correct |
3 |
Correct |
90 ms |
59344 KB |
Output is correct |
4 |
Correct |
81 ms |
59344 KB |
Output is correct |
5 |
Partially correct |
89 ms |
59344 KB |
Partially correct |
6 |
Correct |
83 ms |
59344 KB |
Output is correct |
7 |
Correct |
74 ms |
59344 KB |
Output is correct |
8 |
Correct |
83 ms |
59344 KB |
Output is correct |
9 |
Correct |
70 ms |
59344 KB |
Output is correct |
10 |
Correct |
79 ms |
59344 KB |
Output is correct |
11 |
Correct |
79 ms |
59344 KB |
Output is correct |
12 |
Correct |
79 ms |
59344 KB |
Output is correct |
13 |
Correct |
73 ms |
59344 KB |
Output is correct |
14 |
Correct |
78 ms |
59344 KB |
Output is correct |
15 |
Correct |
77 ms |
59344 KB |
Output is correct |
16 |
Correct |
73 ms |
59344 KB |
Output is correct |
17 |
Correct |
70 ms |
59344 KB |
Output is correct |
18 |
Correct |
75 ms |
59344 KB |
Output is correct |
19 |
Correct |
76 ms |
59344 KB |
Output is correct |
20 |
Incorrect |
77 ms |
59344 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
59344 KB |
Output is correct |
2 |
Correct |
90 ms |
59344 KB |
Output is correct |
3 |
Correct |
102 ms |
59344 KB |
Output is correct |
4 |
Correct |
79 ms |
59344 KB |
Output is correct |
5 |
Correct |
73 ms |
59344 KB |
Output is correct |
6 |
Correct |
71 ms |
59344 KB |
Output is correct |
7 |
Correct |
86 ms |
59344 KB |
Output is correct |
8 |
Correct |
82 ms |
59344 KB |
Output is correct |
9 |
Correct |
91 ms |
59344 KB |
Output is correct |
10 |
Correct |
75 ms |
59344 KB |
Output is correct |
11 |
Correct |
89 ms |
59344 KB |
Output is correct |
12 |
Correct |
88 ms |
59344 KB |
Output is correct |
13 |
Correct |
88 ms |
59344 KB |
Output is correct |
14 |
Correct |
80 ms |
59344 KB |
Output is correct |
15 |
Correct |
78 ms |
59344 KB |
Output is correct |
16 |
Correct |
83 ms |
59344 KB |
Output is correct |
17 |
Correct |
101 ms |
59344 KB |
Output is correct |
18 |
Correct |
74 ms |
59344 KB |
Output is correct |
19 |
Correct |
79 ms |
59344 KB |
Output is correct |
20 |
Incorrect |
67 ms |
59344 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |