#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]]);
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 |
62 ms |
55608 KB |
Output is correct |
2 |
Correct |
60 ms |
55916 KB |
Output is correct |
3 |
Correct |
55 ms |
56016 KB |
Output is correct |
4 |
Correct |
55 ms |
56016 KB |
Output is correct |
5 |
Correct |
60 ms |
56016 KB |
Output is correct |
6 |
Correct |
52 ms |
56016 KB |
Output is correct |
7 |
Correct |
55 ms |
56016 KB |
Output is correct |
8 |
Correct |
67 ms |
56016 KB |
Output is correct |
9 |
Correct |
55 ms |
56120 KB |
Output is correct |
10 |
Correct |
65 ms |
56120 KB |
Output is correct |
11 |
Correct |
64 ms |
56168 KB |
Output is correct |
12 |
Correct |
61 ms |
56168 KB |
Output is correct |
13 |
Correct |
56 ms |
56268 KB |
Output is correct |
14 |
Correct |
57 ms |
56368 KB |
Output is correct |
15 |
Correct |
59 ms |
56368 KB |
Output is correct |
16 |
Correct |
58 ms |
56368 KB |
Output is correct |
17 |
Correct |
54 ms |
56368 KB |
Output is correct |
18 |
Correct |
65 ms |
56368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
58660 KB |
Output is correct |
2 |
Correct |
94 ms |
58856 KB |
Output is correct |
3 |
Correct |
102 ms |
58856 KB |
Output is correct |
4 |
Correct |
84 ms |
58856 KB |
Output is correct |
5 |
Correct |
86 ms |
58856 KB |
Output is correct |
6 |
Correct |
81 ms |
58856 KB |
Output is correct |
7 |
Correct |
90 ms |
58856 KB |
Output is correct |
8 |
Correct |
81 ms |
58856 KB |
Output is correct |
9 |
Correct |
92 ms |
58856 KB |
Output is correct |
10 |
Correct |
80 ms |
58856 KB |
Output is correct |
11 |
Correct |
80 ms |
58856 KB |
Output is correct |
12 |
Correct |
83 ms |
58856 KB |
Output is correct |
13 |
Correct |
81 ms |
58856 KB |
Output is correct |
14 |
Correct |
87 ms |
58856 KB |
Output is correct |
15 |
Correct |
82 ms |
58856 KB |
Output is correct |
16 |
Correct |
89 ms |
58856 KB |
Output is correct |
17 |
Correct |
99 ms |
58856 KB |
Output is correct |
18 |
Correct |
86 ms |
58856 KB |
Output is correct |
19 |
Correct |
88 ms |
58856 KB |
Output is correct |
20 |
Runtime error |
121 ms |
87404 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
115952 KB |
Output is correct |
2 |
Correct |
62 ms |
115952 KB |
Output is correct |
3 |
Correct |
62 ms |
115952 KB |
Output is correct |
4 |
Correct |
67 ms |
115952 KB |
Output is correct |
5 |
Correct |
62 ms |
115952 KB |
Output is correct |
6 |
Correct |
63 ms |
115952 KB |
Output is correct |
7 |
Correct |
65 ms |
115952 KB |
Output is correct |
8 |
Correct |
65 ms |
115952 KB |
Output is correct |
9 |
Correct |
81 ms |
116272 KB |
Output is correct |
10 |
Correct |
88 ms |
116336 KB |
Output is correct |
11 |
Correct |
81 ms |
116336 KB |
Output is correct |
12 |
Correct |
69 ms |
116336 KB |
Output is correct |
13 |
Correct |
67 ms |
116336 KB |
Output is correct |
14 |
Correct |
64 ms |
116336 KB |
Output is correct |
15 |
Correct |
64 ms |
116336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
116336 KB |
Output is correct |
2 |
Correct |
98 ms |
116336 KB |
Output is correct |
3 |
Correct |
102 ms |
116336 KB |
Output is correct |
4 |
Correct |
92 ms |
116336 KB |
Output is correct |
5 |
Partially correct |
84 ms |
116336 KB |
Partially correct |
6 |
Correct |
84 ms |
116336 KB |
Output is correct |
7 |
Correct |
90 ms |
116336 KB |
Output is correct |
8 |
Correct |
81 ms |
116336 KB |
Output is correct |
9 |
Correct |
94 ms |
116336 KB |
Output is correct |
10 |
Correct |
90 ms |
116336 KB |
Output is correct |
11 |
Correct |
84 ms |
116336 KB |
Output is correct |
12 |
Correct |
83 ms |
116336 KB |
Output is correct |
13 |
Correct |
88 ms |
116336 KB |
Output is correct |
14 |
Correct |
86 ms |
116336 KB |
Output is correct |
15 |
Correct |
84 ms |
116336 KB |
Output is correct |
16 |
Correct |
81 ms |
116336 KB |
Output is correct |
17 |
Correct |
90 ms |
116336 KB |
Output is correct |
18 |
Correct |
88 ms |
116336 KB |
Output is correct |
19 |
Correct |
89 ms |
116336 KB |
Output is correct |
20 |
Runtime error |
134 ms |
116336 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
116336 KB |
Output is correct |
2 |
Correct |
110 ms |
116336 KB |
Output is correct |
3 |
Correct |
96 ms |
116336 KB |
Output is correct |
4 |
Correct |
92 ms |
116336 KB |
Output is correct |
5 |
Correct |
91 ms |
116336 KB |
Output is correct |
6 |
Correct |
89 ms |
116336 KB |
Output is correct |
7 |
Correct |
84 ms |
116336 KB |
Output is correct |
8 |
Correct |
91 ms |
116336 KB |
Output is correct |
9 |
Correct |
84 ms |
116336 KB |
Output is correct |
10 |
Correct |
93 ms |
116336 KB |
Output is correct |
11 |
Correct |
86 ms |
116336 KB |
Output is correct |
12 |
Correct |
89 ms |
116336 KB |
Output is correct |
13 |
Correct |
86 ms |
116336 KB |
Output is correct |
14 |
Correct |
88 ms |
116336 KB |
Output is correct |
15 |
Correct |
98 ms |
116336 KB |
Output is correct |
16 |
Correct |
91 ms |
116336 KB |
Output is correct |
17 |
Correct |
92 ms |
116336 KB |
Output is correct |
18 |
Correct |
84 ms |
116336 KB |
Output is correct |
19 |
Correct |
92 ms |
116336 KB |
Output is correct |
20 |
Runtime error |
126 ms |
116336 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
21 |
Halted |
0 ms |
0 KB |
- |