#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
typedef long long ll;
static void solve2(int N, int M, int A[], int B[], ll X) {
vector<bool> bits;
while (X) {
bits.push_back(X&1);
X >>= 1;
}
reverse(bits.begin(), bits.end());
for (int i = 0, k = 0; i < N; i++) {
if (i+bits.size() < N) MessageBoard(i, 0);
else MessageBoard(i, bits[k++]);
}
}
static void solve3(int N, int M, int A[], int B[], ll X) {
vector<bool> bits;
while (X || bits.size() < 60) {
bits.push_back(X&1);
X >>= 1;
}
reverse(bits.begin(), bits.end());
for (int i = 0, k = 0; i < N; i++) {
MessageBoard(i, bits[i%60]);
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T) {
if (T <= 2) solve2(N,M,A,B,X);
else if (T == 3) solve3(N,M,A,B,X);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long ll;
const int MAXN = 100000;
static vector<int> g[MAXN];
static ll solve2(int N, int M, int A[], int B[], int P, int V) {
vector<bool> val(N);
vector<bool> visisted(N);
val[P] = V;
function<void(int)> dfs;
dfs = [&](int cur) {
visisted[cur] = true;
for (int nx : g[cur]) {
if (visisted[nx]) continue;
val[nx] = Move(nx);
dfs(nx);
Move(cur);
}
};
dfs(P);
ll ans = 0;
for (int i = 0; i < N; i++) {
ans <<= 1;
ans |= (int) val[i];
}
return ans;
}
static ll solve3(int N, int M, int A[], int B[], int P, int V) {
int start = (P/60)*60;
if (start + 60 >= N) start -= 60;
while (P-1 != start)
Move(--P);
vector<bool> val(60);
if (P == start) val[0] = V;
else val[0] = Move(P = start);
for (int i = 1; i < 60; i++)
val[i] = Move(++P);
ll ans = 0;
for (int i = 0; i < 60; i++) {
ans <<= 1;
ans |= (int) val[i];
}
return ans;
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for (int i = 0; i < M; i++) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
if (T <= 2) solve2(N,M,A,B,P,V);
else if (T == 3) solve2(N,M,A,B,P,V);
else return 0;
}
Compilation message
Joi.cpp: In function 'void solve2(int, int, int*, int*, ll)':
Joi.cpp:17:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i+bits.size() < N) MessageBoard(i, 0);
^
Joi.cpp: In function 'void solve3(int, int, int*, int*, ll)':
Joi.cpp:31:18: warning: unused variable 'k' [-Wunused-variable]
for (int i = 0, k = 0; i < N; i++) {
^
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Ioi.cpp: At global scope:
Ioi.cpp:38:11: warning: 'll solve3(int, int, int*, int*, int, int)' defined but not used [-Wunused-function]
static ll solve3(int N, int M, int A[], int B[], int P, int V) {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
7100 KB |
Output is correct |
2 |
Correct |
0 ms |
7100 KB |
Output is correct |
3 |
Correct |
0 ms |
7100 KB |
Output is correct |
4 |
Correct |
0 ms |
7100 KB |
Output is correct |
5 |
Correct |
0 ms |
7100 KB |
Output is correct |
6 |
Correct |
0 ms |
7100 KB |
Output is correct |
7 |
Correct |
0 ms |
7100 KB |
Output is correct |
8 |
Correct |
0 ms |
7100 KB |
Output is correct |
9 |
Correct |
0 ms |
7100 KB |
Output is correct |
10 |
Correct |
0 ms |
7100 KB |
Output is correct |
11 |
Correct |
6 ms |
7232 KB |
Output is correct |
12 |
Correct |
0 ms |
7100 KB |
Output is correct |
13 |
Correct |
0 ms |
7100 KB |
Output is correct |
14 |
Correct |
0 ms |
7100 KB |
Output is correct |
15 |
Correct |
0 ms |
7100 KB |
Output is correct |
16 |
Correct |
0 ms |
7100 KB |
Output is correct |
17 |
Correct |
3 ms |
7100 KB |
Output is correct |
18 |
Correct |
0 ms |
7100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
7924 KB |
Output is correct |
2 |
Correct |
36 ms |
7928 KB |
Output is correct |
3 |
Correct |
22 ms |
7932 KB |
Output is correct |
4 |
Correct |
15 ms |
7496 KB |
Output is correct |
5 |
Correct |
15 ms |
8088 KB |
Output is correct |
6 |
Correct |
15 ms |
7748 KB |
Output is correct |
7 |
Correct |
9 ms |
7720 KB |
Output is correct |
8 |
Correct |
12 ms |
7708 KB |
Output is correct |
9 |
Correct |
18 ms |
7628 KB |
Output is correct |
10 |
Correct |
15 ms |
7560 KB |
Output is correct |
11 |
Correct |
9 ms |
7560 KB |
Output is correct |
12 |
Correct |
12 ms |
7364 KB |
Output is correct |
13 |
Correct |
15 ms |
7364 KB |
Output is correct |
14 |
Correct |
22 ms |
7364 KB |
Output is correct |
15 |
Correct |
15 ms |
7496 KB |
Output is correct |
16 |
Correct |
15 ms |
7496 KB |
Output is correct |
17 |
Correct |
12 ms |
7496 KB |
Output is correct |
18 |
Correct |
16 ms |
7496 KB |
Output is correct |
19 |
Correct |
16 ms |
7496 KB |
Output is correct |
20 |
Correct |
12 ms |
7476 KB |
Output is correct |
21 |
Correct |
15 ms |
7472 KB |
Output is correct |
22 |
Correct |
12 ms |
7472 KB |
Output is correct |
23 |
Correct |
12 ms |
7472 KB |
Output is correct |
24 |
Correct |
12 ms |
7476 KB |
Output is correct |
25 |
Correct |
12 ms |
7472 KB |
Output is correct |
26 |
Correct |
12 ms |
7476 KB |
Output is correct |
27 |
Correct |
15 ms |
7476 KB |
Output is correct |
28 |
Correct |
9 ms |
7472 KB |
Output is correct |
29 |
Correct |
12 ms |
7448 KB |
Output is correct |
30 |
Correct |
12 ms |
7464 KB |
Output is correct |
31 |
Correct |
0 ms |
7100 KB |
Output is correct |
32 |
Correct |
0 ms |
7100 KB |
Output is correct |
33 |
Correct |
0 ms |
7100 KB |
Output is correct |
34 |
Correct |
0 ms |
7100 KB |
Output is correct |
35 |
Correct |
0 ms |
7100 KB |
Output is correct |
36 |
Correct |
0 ms |
7100 KB |
Output is correct |
37 |
Correct |
0 ms |
7100 KB |
Output is correct |
38 |
Correct |
0 ms |
7100 KB |
Output is correct |
39 |
Correct |
0 ms |
7100 KB |
Output is correct |
40 |
Correct |
3 ms |
7100 KB |
Output is correct |
41 |
Correct |
0 ms |
7100 KB |
Output is correct |
42 |
Correct |
0 ms |
7100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
7100 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
7100 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
7100 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |