#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 + 59 >= 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) solve3(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]
}
^
# |
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 |
36 ms |
7932 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
9 ms |
7100 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
7100 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |