#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int _N = 1e4+1, _B = 60;
vector<int> g[_N];
bool vis[_N];
int cnt_preorder, preord[_N];
ll X;
void dfs(int x) {
vis[x] = 1;
preord[x] = cnt_preorder;
cnt_preorder++;
for(int i: g[x]) {
if(!vis[i]) {
dfs(i);
}
}
}
void Joi(int N, int M, int A[], int B[], ll _X, int T) {
// MessageBoard();
X = _X;
for(int i=0; i<M; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) {
sort(g[i].begin(), g[i].end());
}
dfs(0);
for(int i=0; i<N; ++i) {
int set_bit = preord[i]%_B;
MessageBoard(i, (bool)(X&(1LL<<set_bit)));
}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int __N = 1e4+1;
const int bits = 60;
int par[__N];
bool added[bits];
int cur, val;
int cnt_mv;
int value[__N];
bool is_set[__N];
void mv(int x) {
cnt_mv++;
if(cnt_mv<2*bits) {
cur = x;
val = Move(x);
value[x] = val;
is_set[x] = 1;
}
else {
cur = -1;
}
}
void _dfs(int x, vector<int>& vis, vector<vector<int>>& g, vector<int>& preorder, int& nr) {
vis[x] = 1;
preorder[x] = nr;
nr++;
for(int i: g[x]) {
if(!vis[i]) {
par[i] = x;
if(x==cur) mv(i);
_dfs(i, vis, g, preorder, nr);
}
}
if(x==cur && x != 0) {
mv(par[x]);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
vector<vector<int>> g(N);
vector<int> vis(N), preorder(N);
int nr = 0;
for(int i=0; i<M; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) {
sort(g[i].begin(), g[i].end());
}
cur = P;
val = V;
_dfs(0, vis, g, preorder, nr);
ll X = 0;
for(int i=0; i<N; ++i) {
if(is_set[i]) {
int bit = preorder[i]%bits;
if(!added[bit]) {
X += (ll)value[i] * (1LL<<bit);
added[bit]=1;
}
}
}
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1024 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1036 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
4820 KB |
Output is correct |
2 |
Correct |
32 ms |
4528 KB |
Output is correct |
3 |
Incorrect |
31 ms |
4524 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1036 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
1 ms |
1024 KB |
Output is correct |
4 |
Correct |
4 ms |
1572 KB |
Output is correct |
5 |
Correct |
3 ms |
1668 KB |
Output is correct |
6 |
Correct |
4 ms |
1664 KB |
Output is correct |
7 |
Correct |
3 ms |
1672 KB |
Output is correct |
8 |
Correct |
4 ms |
1668 KB |
Output is correct |
9 |
Correct |
15 ms |
4412 KB |
Output is correct |
10 |
Correct |
16 ms |
4044 KB |
Output is correct |
11 |
Correct |
15 ms |
4044 KB |
Output is correct |
12 |
Correct |
2 ms |
1160 KB |
Output is correct |
13 |
Correct |
2 ms |
1032 KB |
Output is correct |
14 |
Correct |
2 ms |
1036 KB |
Output is correct |
15 |
Correct |
2 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4324 KB |
Output is correct |
2 |
Correct |
31 ms |
4452 KB |
Output is correct |
3 |
Incorrect |
31 ms |
4528 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4664 KB |
Output is correct |
2 |
Incorrect |
31 ms |
4324 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |