#include <bits/stdc++.h>
#include "Joi.h"
#define f first
#define s second
using namespace std;
typedef long long ll;
const int jZ = 1e4+5;
vector<ll> jadj[jZ], jG[jZ];
ll jdisc[jZ], jt[jZ], jcn, n, jrqm, jC = 60;
void jDFS(ll u, ll p)
{
jdisc[u] = jcn;
jt[jcn] = u;
MessageBoard(u, (jrqm>>(jcn%jC))&1);
//cout << u << " " << jadj[u].size() << endl;
jcn++;
for(int v : jadj[u])
{
//cout << v << " " << jdisc[v] << endl;
if(v == p || jdisc[v] != -1) continue;
jDFS(v, u);
}
if(p != -1) jG[u].push_back(p), jG[p].push_back(u);
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
memset(jdisc, -1, sizeof jdisc);
n = N, jrqm = X;
for(int i=0; i<M; i++)
{
jadj[A[i]].push_back(B[i]), jadj[B[i]].push_back(A[i]);
}
for(int i=0; i<n; i++) sort(jadj[i].begin(), jadj[i].end());
jDFS(0, -1);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long ll;
const int Z = 1e4+5;
vector<ll> adj[Z], G[Z];
ll disc[Z], t[Z], cn, n, f, cur, C = 60, l, r, rqm, msg[Z], sub[Z], par[Z];
void DFS(ll u, ll p)
{
disc[u] = cn;
t[cn] = u;
cn++;
sub[u] = 1;
par[u] = p;
for(int v : adj[u])
{
if(v == p || disc[v] != -1) continue;
DFS(v, u), sub[u] += sub[v];
}
if(p != -1) G[u].push_back(p), G[p].push_back(u);
}
void dfs(int u, int p)
{
if(!C) return ;
C--;
for(int v : G[u])
{
if(v == p || v == par[u]) continue;
msg[v] = Move(v);
dfs(v, u);
Move(u);
}
}
void operate()
{
dfs(cur, par[cur]);
// while(C)
// {
// assert(cur, -1);
// msg[par[cur]] = Move(par[cur]), C--;
// dfs(par[cur], cur);
// cur = par[cur];
// }
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
memset(disc, -1, sizeof disc);
memset(msg, -1, sizeof msg);
n = N, cur = P, msg[cur] = V;
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());
DFS(0, -1);
// for(int i=0; i<n; i++)
// {
// cout << i << " : ";
// for(int v : G[i]) cout << v << " ";
// cout << endl;
// }
operate();
ll ret = 0;
C = 60;
for(int i=0; i<n; i++)
{
if(msg[i] == -1) continue;
int bit = i%C;
ret |= ((1<<bit)*msg[i]);
//cout << msg[i] << " " << ret << " " << bit << endl;
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2044 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
6396 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2032 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
6320 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
6200 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |