#include <bits/stdc++.h>
#include "Joi.h"
#pragma GCC target("sse,sse2,avx2")
#pragma GCC optimize("unroll-loops,O3")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
constexpr int N = 1e6+10,mod = 1e9+7;
vector<int> aadj[N];
int TT,ttin[N];
bool vvis[N];
void dfs(int v,ll x){
if ((x&(1ll << (TT%60)))) MessageBoard(v,1);
else MessageBoard(v,0);
ttin[v] = TT++;
vvis[v] = 1;
for (int u : aadj[v]) if (!vvis[u]) dfs(u,x);
}
void Joi(int n, int m, int A[], int B[], long long x, int tt) {
rep(i,0,m){
aadj[A[i]].pb(B[i]);
aadj[B[i]].pb(A[i]);
}
rep(i,0,n) sort(all(aadj[i]));
dfs(0,x);
return;
}
#include "Ioi.h"
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,avx2")
#pragma GCC optimize("unroll-loops,O3")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
constexpr int N = 1e6+10,mod = 1e9+7;
constexpr ll inf = 1e9+10;
vector<int> adj[N];
bool vis[N];
int tin[N],T;
int par[N],ans[70];
int po[N],h[N];
void dfs(int v){
vis[v] = 1;
tin[v] = T++;
for (int u : adj[v]) if (!vis[u]){
h[u] = h[v]+1;
par[u] = v;
dfs(u);
}
}
long long Ioi(int n, int m, int A[], int B[], int P, int v, int tt) {
rep(i,0,m){
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
rep(i,0,n) sort(all(adj[i]));
dfs(0);
memset(ans,-1,sizeof ans);
swap(P,v);
int cur = v;
ans[tin[cur]%60] = P;
int cnt = 1;
while (cnt < 60){
int fl = -1;
int sz = adj[cur].size();
while (po[cur] < sz){
int u = adj[cur][po[cur]];
po[cur]++;
if (par[u] != cur) continue;
fl = u;
break;
}
if (fl == -1)
fl = par[cur];
int t = tin[fl]%60;
if (ans[t] == -1) cnt++;
ans[t] = Move(fl);
cur = fl;
}
ll out = 0;
rep(i,0,60) if (ans[i]) out += (1ll << i);
return out;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
47668 KB |
Output is correct |
2 |
Correct |
24 ms |
47684 KB |
Output is correct |
3 |
Correct |
24 ms |
47660 KB |
Output is correct |
4 |
Correct |
24 ms |
47636 KB |
Output is correct |
5 |
Correct |
24 ms |
47664 KB |
Output is correct |
6 |
Correct |
24 ms |
47664 KB |
Output is correct |
7 |
Correct |
27 ms |
47548 KB |
Output is correct |
8 |
Correct |
26 ms |
47736 KB |
Output is correct |
9 |
Correct |
24 ms |
47744 KB |
Output is correct |
10 |
Correct |
26 ms |
47700 KB |
Output is correct |
11 |
Correct |
27 ms |
48112 KB |
Output is correct |
12 |
Correct |
23 ms |
47624 KB |
Output is correct |
13 |
Correct |
26 ms |
47636 KB |
Output is correct |
14 |
Correct |
24 ms |
47720 KB |
Output is correct |
15 |
Correct |
25 ms |
47764 KB |
Output is correct |
16 |
Correct |
25 ms |
47676 KB |
Output is correct |
17 |
Correct |
27 ms |
47668 KB |
Output is correct |
18 |
Correct |
25 ms |
47624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
50312 KB |
Output is correct |
2 |
Correct |
47 ms |
50296 KB |
Output is correct |
3 |
Correct |
45 ms |
50460 KB |
Output is correct |
4 |
Correct |
35 ms |
49188 KB |
Output is correct |
5 |
Correct |
38 ms |
49504 KB |
Output is correct |
6 |
Correct |
36 ms |
49408 KB |
Output is correct |
7 |
Correct |
37 ms |
49364 KB |
Output is correct |
8 |
Correct |
35 ms |
49384 KB |
Output is correct |
9 |
Correct |
34 ms |
49308 KB |
Output is correct |
10 |
Correct |
36 ms |
49192 KB |
Output is correct |
11 |
Correct |
38 ms |
49280 KB |
Output is correct |
12 |
Correct |
36 ms |
49108 KB |
Output is correct |
13 |
Correct |
35 ms |
49092 KB |
Output is correct |
14 |
Correct |
37 ms |
49240 KB |
Output is correct |
15 |
Correct |
35 ms |
49216 KB |
Output is correct |
16 |
Correct |
38 ms |
49180 KB |
Output is correct |
17 |
Correct |
36 ms |
49148 KB |
Output is correct |
18 |
Correct |
38 ms |
49108 KB |
Output is correct |
19 |
Correct |
38 ms |
49132 KB |
Output is correct |
20 |
Correct |
33 ms |
49524 KB |
Output is correct |
21 |
Correct |
36 ms |
49320 KB |
Output is correct |
22 |
Correct |
37 ms |
49472 KB |
Output is correct |
23 |
Correct |
36 ms |
49436 KB |
Output is correct |
24 |
Correct |
37 ms |
49396 KB |
Output is correct |
25 |
Correct |
36 ms |
49432 KB |
Output is correct |
26 |
Correct |
39 ms |
49436 KB |
Output is correct |
27 |
Correct |
41 ms |
49484 KB |
Output is correct |
28 |
Correct |
36 ms |
49416 KB |
Output is correct |
29 |
Correct |
33 ms |
49340 KB |
Output is correct |
30 |
Correct |
35 ms |
49388 KB |
Output is correct |
31 |
Correct |
25 ms |
47564 KB |
Output is correct |
32 |
Correct |
25 ms |
47664 KB |
Output is correct |
33 |
Correct |
24 ms |
47668 KB |
Output is correct |
34 |
Correct |
28 ms |
47672 KB |
Output is correct |
35 |
Correct |
24 ms |
47672 KB |
Output is correct |
36 |
Correct |
24 ms |
47648 KB |
Output is correct |
37 |
Correct |
24 ms |
47684 KB |
Output is correct |
38 |
Correct |
23 ms |
47728 KB |
Output is correct |
39 |
Correct |
24 ms |
47680 KB |
Output is correct |
40 |
Correct |
26 ms |
47648 KB |
Output is correct |
41 |
Correct |
27 ms |
47624 KB |
Output is correct |
42 |
Correct |
26 ms |
47760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
47664 KB |
Output is correct |
2 |
Correct |
25 ms |
47792 KB |
Output is correct |
3 |
Correct |
24 ms |
47672 KB |
Output is correct |
4 |
Correct |
26 ms |
47896 KB |
Output is correct |
5 |
Correct |
28 ms |
47860 KB |
Output is correct |
6 |
Correct |
26 ms |
47924 KB |
Output is correct |
7 |
Correct |
28 ms |
47928 KB |
Output is correct |
8 |
Correct |
31 ms |
48084 KB |
Output is correct |
9 |
Correct |
41 ms |
49512 KB |
Output is correct |
10 |
Correct |
35 ms |
49716 KB |
Output is correct |
11 |
Correct |
37 ms |
49652 KB |
Output is correct |
12 |
Correct |
26 ms |
47652 KB |
Output is correct |
13 |
Correct |
26 ms |
47624 KB |
Output is correct |
14 |
Correct |
26 ms |
47720 KB |
Output is correct |
15 |
Correct |
24 ms |
47696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
50552 KB |
Output is correct |
2 |
Correct |
46 ms |
50296 KB |
Output is correct |
3 |
Correct |
46 ms |
50324 KB |
Output is correct |
4 |
Correct |
36 ms |
49144 KB |
Output is correct |
5 |
Partially correct |
36 ms |
49560 KB |
Partially correct |
6 |
Correct |
35 ms |
49376 KB |
Output is correct |
7 |
Correct |
39 ms |
49380 KB |
Output is correct |
8 |
Correct |
36 ms |
49384 KB |
Output is correct |
9 |
Correct |
35 ms |
49316 KB |
Output is correct |
10 |
Correct |
35 ms |
49296 KB |
Output is correct |
11 |
Correct |
35 ms |
49300 KB |
Output is correct |
12 |
Correct |
35 ms |
49104 KB |
Output is correct |
13 |
Correct |
35 ms |
49156 KB |
Output is correct |
14 |
Correct |
36 ms |
49136 KB |
Output is correct |
15 |
Partially correct |
37 ms |
49368 KB |
Partially correct |
16 |
Partially correct |
37 ms |
49248 KB |
Partially correct |
17 |
Correct |
36 ms |
49304 KB |
Output is correct |
18 |
Partially correct |
35 ms |
49192 KB |
Partially correct |
19 |
Partially correct |
36 ms |
49156 KB |
Partially correct |
20 |
Correct |
33 ms |
49412 KB |
Output is correct |
21 |
Correct |
35 ms |
49572 KB |
Output is correct |
22 |
Correct |
37 ms |
49432 KB |
Output is correct |
23 |
Correct |
37 ms |
49300 KB |
Output is correct |
24 |
Correct |
39 ms |
49376 KB |
Output is correct |
25 |
Correct |
36 ms |
49388 KB |
Output is correct |
26 |
Correct |
35 ms |
49428 KB |
Output is correct |
27 |
Correct |
36 ms |
49596 KB |
Output is correct |
28 |
Correct |
39 ms |
49408 KB |
Output is correct |
29 |
Correct |
36 ms |
49336 KB |
Output is correct |
30 |
Correct |
35 ms |
49248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
50464 KB |
Output is correct |
2 |
Correct |
44 ms |
50436 KB |
Output is correct |
3 |
Correct |
49 ms |
50396 KB |
Output is correct |
4 |
Incorrect |
39 ms |
49144 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |