#include "Joi.h"
#include "bits/stdc++.h"
using namespace std;
vector<int> adj2[12269];
bool vis2[12269];
int val2[12269];
void dfs2(int node, long long X, int par) {
if(par == -1) val2[node] = 0;
else val2[node] = (val2[par] + 1) % 60;
long long res = (X & (1ll << val2[node]));
MessageBoard(node, (res > 0 ? 1 : 0));
vis2[node] = 1;
for(int x: adj2[node]) {
if(!vis2[x]) {
dfs2(x, X, node);
}
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for(int i=0; i<M; i++) {
adj2[A[i]].push_back(B[i]);
adj2[B[i]].push_back(A[i]);
}
for(int i=0; i<N; i++) {
sort(adj2[i].begin(), adj2[i].end());
}
for(int i=0; i<N; i++) {
vis2[i] = 0;
}
dfs2(0, X, -1);
}
#include "Ioi.h"
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e4 + 10;
vector<int> adj[MAXN];
bool vis[MAXN];
int val[MAXN];
void dfs(int node, int par) {
if(par == -1) val[node] = 0;
else val[node] = (val[par] + 1) % 60;
vis[node] = 1;
for(int x: adj[node]) {
if(!vis[x]) {
dfs(x, node);
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i=0; i<M; i++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
for(int i=0; i<N; i++) {
sort(adj[i].begin(), adj[i].end());
}
for(int i=0; i<N; i++) {
vis[i] = 0;
}
dfs(0, -1);
int cur = P;
long long ans = 0;
int res[60];
for(int i=0; i<60; i++) res[i] = 0;
res[val[P]] = V;
for(int i=val[P]-1; i>=0; i--) {
for(int x: adj[cur]) {
if(val[x] == i) {
cur = x;
res[i] = Move(cur);
break;
}
}
}
if(cur == 0) {
for(int i=1; i<60; i++) {
for(int x: adj[cur]) {
if(val[x] == i) {
cur = x;
res[i] = Move(cur);
break;
}
}
}
}
else {
for(int i=59; i>=0; i--) {
for(int x: adj[cur]) {
if(val[x] == i) {
cur = x;
res[i] = Move(cur);
break;
}
}
}
}
for(int i=0; i<60; i++) {
if(res[i]) ans += (1ll << i);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1152 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
3996 KB |
Output is correct |
2 |
Correct |
20 ms |
4084 KB |
Output is correct |
3 |
Correct |
20 ms |
4036 KB |
Output is correct |
4 |
Incorrect |
11 ms |
2756 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1152 KB |
Output is correct |
2 |
Correct |
0 ms |
1152 KB |
Output is correct |
3 |
Correct |
0 ms |
1152 KB |
Output is correct |
4 |
Correct |
2 ms |
1452 KB |
Output is correct |
5 |
Correct |
3 ms |
1436 KB |
Output is correct |
6 |
Correct |
2 ms |
1440 KB |
Output is correct |
7 |
Correct |
2 ms |
1444 KB |
Output is correct |
8 |
Correct |
2 ms |
1436 KB |
Output is correct |
9 |
Correct |
9 ms |
3524 KB |
Output is correct |
10 |
Correct |
9 ms |
3548 KB |
Output is correct |
11 |
Correct |
9 ms |
3532 KB |
Output is correct |
12 |
Correct |
0 ms |
1152 KB |
Output is correct |
13 |
Correct |
0 ms |
1160 KB |
Output is correct |
14 |
Correct |
0 ms |
1152 KB |
Output is correct |
15 |
Correct |
0 ms |
1156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
4056 KB |
Output is correct |
2 |
Correct |
19 ms |
3960 KB |
Output is correct |
3 |
Correct |
20 ms |
3992 KB |
Output is correct |
4 |
Incorrect |
11 ms |
2760 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3956 KB |
Output is correct |
2 |
Correct |
19 ms |
3972 KB |
Output is correct |
3 |
Correct |
20 ms |
4040 KB |
Output is correct |
4 |
Incorrect |
11 ms |
2764 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |