#include "bits/stdc++.h"
using namespace std;
#include "Joi.h"
//~ int a[20005];
//~ void MessageBoard(int x, int v){
//~ a[x] = v;
//~ }
//~ int Move(int x){
//~ return a[x];
//~ }
//~ namespace JOI{
const int NN = 1e4 + 5;
vector<int> G[NN], tt;
int used[NN], d[NN];
void dfs(int u){
used[u] = 1;
tt.push_back(u);
for(auto x : G[u]){
if(used[x]) continue;
d[x] = d[u] + 1;
dfs(x);
}
}
void Joi(int n, int m, int a[], int b[], long long x, int t) {
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());
}
d[0] = 1;
dfs(0);
bool ok = 0;
for(int i=0;i<n;i++){
if(d[i] >= 60){
ok = 1;
}
}
//~ cout<<"here"<<endl;
if(ok){
for(int i=0;i<n;i++){ d[i] = (d[i] - 1) % 60;
MessageBoard(i, x >> d[i] & 1);
}
} else {
for(int i=0;i<min(n, 60);i++){
MessageBoard(tt[i], x >> i & 1);
} for(int i=60;i<n;i++){
MessageBoard(tt[i], 0);
}
}
}
//~ }
//~ namespace IOI{
//~ const int NN = 1e4 + 5;
//~ vector<int> G[NN], tt;
//~ int used[NN], par[NN], d[NN];
//~ void dfs(int u){
//~ used[u] = 1;
//~ tt.push_back(u);
//~ for(auto x : G[u]){
//~ if(used[x]) continue;
//~ d[x] = d[u] + 1,
//~ par[x] = u, dfs(x);
//~ tt.push_back(u);
//~ }
//~ }
//~ long long 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]);
//~ }
//~ for(int i=0;i<n;i++) sort(G[i].begin(), G[i].end());
//~ d[0] = 1;
//~ dfs(0);
//~ bool ok = 0;
//~ int r = 0;
//~ for(int i=0;i<n;i++){
//~ if(d[i] >= 60) ok = 1, r = i;
//~ }
//~ long long x = 0;
//~ if(ok){
//~ if(d[p] >= 60){
//~ for(int j=0;j<60;j++){ d[p] = (d[p] - 1) % 60;
//~ x |= ((v * 1ll) << d[p]);
//~ if(p) v = Move(par[p]), p = par[p];
//~ } return x;
//~ } else {
//~ while(p) v = Move(par[p]), p = par[p];
//~ vector<int> tt;
//~ while(r) tt.push_back(r), r = par[r];
//~ for(int i=0;i<60;i++){ d[p] = (d[p] - 1) % 60;
//~ x |= ((v * 1ll) << d[p]);
//~ if(!tt.empty()){
//~ v = Move(tt.back()), p = tt.back();
//~ tt.pop_back();
//~ }
//~ } return x;
//~ }
//~ }
//~ while(p) v = Move(par[p]), p = par[p];
//~ memset(used, 0, sizeof used);
//~ int cnt = 1;
//~ assert(!tt[0]);
//~ for(auto u : tt){
//~ if(u != p) p = u, v = Move(u);
//~ if(used[u]) continue;
//~ used[u] = 1;
//~ x |= ((v * 1ll) << (cnt - 1));
//~ cnt++;
//~ if(cnt == 60) break;
//~ } return x;
//~ }
//~ }
/*
5
4
10
4
1
1 2
1 3
1 4
0 1
*/
//~ signed main(){
//~ freopen("sample-01.txt", "r", stdin);
//~ int n, m, x, p, t; cin>>n>>m>>x>>p>>t;
//~ int a[20005], b[20005];
//~ for(int i=0;i<m;i++){
//~ cin>>a[i]>>b[i];
//~ }
//~ JOI::Joi(n, m, a, b, x, t);
//~ cout<<"here"<<endl;
//~ long long res = IOI::Ioi(n, m, a, b, p, ::a[p], t);
//~ cout<<res<<" "<<x<<"\n";
//~ }
#include "bits/stdc++.h"
using namespace std;
#include "Ioi.h"
//~ #ifndef EVAL
//~ #include "grader.cpp"
//~ #endif
const int NN = 1e4 + 5;
vector<int> G[NN], tt;
int used[NN], par[NN], d[NN];
void dfs(int u){
used[u] = 1;
tt.push_back(u);
for(auto x : G[u]){
if(used[x]) continue;
d[x] = d[u] + 1,
par[x] = u, dfs(x);
tt.push_back(u);
}
}
long long 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]);
}
for(int i=0;i<n;i++) sort(G[i].begin(), G[i].end());
d[0] = 1;
dfs(0);
bool ok = 0;
int r = 0;
for(int i=0;i<n;i++){
if(d[i] >= 60) ok = 1, r = i;
}
long long x = 0;
if(ok){
if(d[p] >= 60){
for(int j=0;j<60;j++){ d[p] = (d[p] - 1) % 60;
x |= ((v * 1ll) << d[p]);
if(p) v = Move(par[p]), p = par[p];
} return x;
} else {
while(p) v = Move(par[p]), p = par[p];
vector<int> tt;
while(r) tt.push_back(r), r = par[r];
for(int i=0;i<60;i++){ d[p] = (d[p] - 1) % 60;
x |= ((v * 1ll) << d[p]);
if(tt.empty()){
v = Move(tt.back()), p = tt.back();
tt.pop_back();
}
} return x;
}
}
while(p) v = Move(par[p]), p = par[p];
memset(used, 0, sizeof used);
int cnt = 1;
assert(!tt[0]);
for(auto u : tt){
if(u != p) p = u, v = Move(u);
if(used[u]) continue;
used[u] = 1;
x |= ((v * 1ll) << (cnt - 1));
cnt++;
if(cnt == 60) break;
} return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1136 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4536 KB |
Output is correct |
2 |
Correct |
19 ms |
4484 KB |
Output is correct |
3 |
Correct |
22 ms |
4620 KB |
Output is correct |
4 |
Correct |
12 ms |
2988 KB |
Output is correct |
5 |
Correct |
16 ms |
3708 KB |
Output is correct |
6 |
Correct |
15 ms |
3624 KB |
Output is correct |
7 |
Correct |
16 ms |
3600 KB |
Output is correct |
8 |
Correct |
14 ms |
3724 KB |
Output is correct |
9 |
Correct |
13 ms |
3648 KB |
Output is correct |
10 |
Incorrect |
12 ms |
3180 KB |
Wrong Answer [7] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1004 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4520 KB |
Output is correct |
2 |
Correct |
22 ms |
4536 KB |
Output is correct |
3 |
Correct |
22 ms |
4508 KB |
Output is correct |
4 |
Correct |
15 ms |
3000 KB |
Output is correct |
5 |
Correct |
13 ms |
4188 KB |
Output is correct |
6 |
Incorrect |
14 ms |
3904 KB |
Wrong Answer [7] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
4540 KB |
Output is correct |
2 |
Correct |
22 ms |
4604 KB |
Output is correct |
3 |
Correct |
27 ms |
4608 KB |
Output is correct |
4 |
Incorrect |
12 ms |
3000 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |