#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++;
cur = x;
if(cnt_mv<2*bits) {
val = Move(x);
value[x] = val;
is_set[x] = 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 |
1044 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1024 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4792 KB |
Output is correct |
2 |
Correct |
32 ms |
4776 KB |
Output is correct |
3 |
Incorrect |
31 ms |
4788 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1284 KB |
Output is correct |
2 |
Correct |
2 ms |
1024 KB |
Output is correct |
3 |
Correct |
2 ms |
1036 KB |
Output is correct |
4 |
Correct |
4 ms |
1672 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1588 KB |
Output is correct |
7 |
Correct |
4 ms |
1588 KB |
Output is correct |
8 |
Correct |
4 ms |
1680 KB |
Output is correct |
9 |
Correct |
17 ms |
4284 KB |
Output is correct |
10 |
Correct |
17 ms |
4140 KB |
Output is correct |
11 |
Correct |
17 ms |
4140 KB |
Output is correct |
12 |
Correct |
2 ms |
1036 KB |
Output is correct |
13 |
Correct |
2 ms |
1044 KB |
Output is correct |
14 |
Correct |
2 ms |
1040 KB |
Output is correct |
15 |
Correct |
2 ms |
1032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4788 KB |
Output is correct |
2 |
Correct |
33 ms |
4788 KB |
Output is correct |
3 |
Incorrect |
38 ms |
4748 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4644 KB |
Output is correct |
2 |
Incorrect |
32 ms |
4644 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |