//Be Name KHODA
#pragma GCC optimize("Ofast")
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int n1 , m1;
vector<int> tr1[10000];
int tms1[10000][2] , ps1[10000];
bool ms1[10000];
int timer1 = -1;
void dfs0(int v1 = 0 , int p1 = -1){
tms1[v1][0] = ++timer1;
ps1[v1] = p1 , ms1[v1] = 1;
for(int u1 : tr1[v1]) if(!ms1[u1]) dfs0(u1 , v1);
tms1[v1][1] = timer1;
}
void Joi(int N , int M , int A[] , int B[] , ll X , int T){
n1 = N , m1 = M;
for(int i = 0 ; i < m1 ; i++) tr1[A[i]].pb(B[i]) , tr1[B[i]].pb(A[i]);
dfs0();
for(int i = 0 ; i < n1 ; i++){
MessageBoard(i , int((X >> (tms1[i][0] % 60)) & 1ll));
}
}
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int n , m;
vector<int> tr[10000];
int tms[10000][2] , ps[10000];
bool ms[10000];
bool is[60];
vector<int> tour;
ll o;
int cur;
int timer = -1;
void dfs1(int v = 0 , int p = -1){
tms[v][0] = ++timer , tour.pb(v);
ps[v] = p , ms[v] = 1;
for(int u : tr[v]) if(!ms[u]) dfs1(u , v) , tour.pb(v);
tms[v][1] = timer;
}
void dfs2(int v){
ms[v] = 1;
for(int u : tr[v]){
if(!ms[u] and u != ps[v] and tms[u][0] < 60){
ll d = (1ll * Move(u));
o |= (d << (tms[u][0] % 60));
dfs2(u);
d = Move(v);
}
}
}
ll Ioi(int N , int M , int A[] , int B[] , int P , int V , int T){
n = N , m = M , cur = P;
for(int i = 0 ; i < m ; i++) tr[A[i]].pb(B[i]) , tr[B[i]].pb(A[i]);
dfs1();
o = ((1ll * V) << (tms[P][0] % 60));
is[tms[P][0] % 60] = 1;
if(tms[P][0] >= 59){
int i = 0;
for(; i < (int)tour.size() ; i++) if(tour[i] == P) break;
while(true){
ll d = Move(tour[i - 1]);
o |= (d << (tms[tour[i - 1]][0] % 60));
i--;
is[tms[tour[i]][0] % 60] = 1;
bool flg = 1;
for(int j = 0 ; j < 60 ; j++) if(!is[j]) flg = 0;
if(flg) break;
}
return o;
}else{
fill(&ms[0] , &ms[n] , 0);
while(true){
dfs2(P);
if(ps[P] == -1) break;
ll d = Move(ps[P]);
P = ps[P];
o |= (d << (tms[P][0] % 60));
}
return o;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1296 KB |
Output is correct |
2 |
Correct |
0 ms |
1308 KB |
Output is correct |
3 |
Correct |
1 ms |
1552 KB |
Output is correct |
4 |
Correct |
0 ms |
1292 KB |
Output is correct |
5 |
Correct |
1 ms |
1304 KB |
Output is correct |
6 |
Correct |
1 ms |
1312 KB |
Output is correct |
7 |
Correct |
1 ms |
1312 KB |
Output is correct |
8 |
Correct |
1 ms |
1304 KB |
Output is correct |
9 |
Correct |
1 ms |
1316 KB |
Output is correct |
10 |
Correct |
1 ms |
1300 KB |
Output is correct |
11 |
Correct |
3 ms |
1640 KB |
Output is correct |
12 |
Correct |
1 ms |
1312 KB |
Output is correct |
13 |
Correct |
1 ms |
1300 KB |
Output is correct |
14 |
Correct |
1 ms |
1308 KB |
Output is correct |
15 |
Correct |
1 ms |
1308 KB |
Output is correct |
16 |
Correct |
1 ms |
1316 KB |
Output is correct |
17 |
Correct |
1 ms |
1316 KB |
Output is correct |
18 |
Correct |
1 ms |
1308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
4316 KB |
Output is correct |
2 |
Correct |
17 ms |
4460 KB |
Output is correct |
3 |
Correct |
17 ms |
4592 KB |
Output is correct |
4 |
Correct |
9 ms |
3040 KB |
Output is correct |
5 |
Correct |
9 ms |
3648 KB |
Output is correct |
6 |
Correct |
10 ms |
3640 KB |
Output is correct |
7 |
Correct |
9 ms |
3636 KB |
Output is correct |
8 |
Correct |
10 ms |
3648 KB |
Output is correct |
9 |
Correct |
10 ms |
3640 KB |
Output is correct |
10 |
Correct |
9 ms |
3388 KB |
Output is correct |
11 |
Correct |
9 ms |
3388 KB |
Output is correct |
12 |
Correct |
9 ms |
3020 KB |
Output is correct |
13 |
Correct |
9 ms |
3104 KB |
Output is correct |
14 |
Correct |
9 ms |
3124 KB |
Output is correct |
15 |
Correct |
9 ms |
3128 KB |
Output is correct |
16 |
Correct |
10 ms |
3128 KB |
Output is correct |
17 |
Correct |
11 ms |
3128 KB |
Output is correct |
18 |
Correct |
10 ms |
3396 KB |
Output is correct |
19 |
Correct |
10 ms |
3340 KB |
Output is correct |
20 |
Correct |
8 ms |
3744 KB |
Output is correct |
21 |
Correct |
11 ms |
3728 KB |
Output is correct |
22 |
Correct |
9 ms |
3640 KB |
Output is correct |
23 |
Correct |
10 ms |
3648 KB |
Output is correct |
24 |
Correct |
9 ms |
3652 KB |
Output is correct |
25 |
Correct |
9 ms |
3660 KB |
Output is correct |
26 |
Correct |
9 ms |
3644 KB |
Output is correct |
27 |
Correct |
9 ms |
3652 KB |
Output is correct |
28 |
Correct |
10 ms |
3652 KB |
Output is correct |
29 |
Correct |
9 ms |
3616 KB |
Output is correct |
30 |
Correct |
11 ms |
3620 KB |
Output is correct |
31 |
Correct |
1 ms |
1312 KB |
Output is correct |
32 |
Correct |
0 ms |
1304 KB |
Output is correct |
33 |
Correct |
1 ms |
1308 KB |
Output is correct |
34 |
Correct |
1 ms |
1304 KB |
Output is correct |
35 |
Correct |
1 ms |
1340 KB |
Output is correct |
36 |
Correct |
0 ms |
1300 KB |
Output is correct |
37 |
Correct |
0 ms |
1312 KB |
Output is correct |
38 |
Correct |
1 ms |
1312 KB |
Output is correct |
39 |
Correct |
1 ms |
1312 KB |
Output is correct |
40 |
Correct |
1 ms |
1304 KB |
Output is correct |
41 |
Correct |
1 ms |
1300 KB |
Output is correct |
42 |
Correct |
1 ms |
1300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1312 KB |
Output is correct |
2 |
Correct |
0 ms |
1292 KB |
Output is correct |
3 |
Correct |
1 ms |
1296 KB |
Output is correct |
4 |
Correct |
2 ms |
2092 KB |
Output is correct |
5 |
Correct |
2 ms |
1848 KB |
Output is correct |
6 |
Correct |
2 ms |
1848 KB |
Output is correct |
7 |
Correct |
2 ms |
1848 KB |
Output is correct |
8 |
Correct |
2 ms |
1848 KB |
Output is correct |
9 |
Correct |
7 ms |
4068 KB |
Output is correct |
10 |
Correct |
8 ms |
4056 KB |
Output is correct |
11 |
Correct |
9 ms |
4052 KB |
Output is correct |
12 |
Correct |
0 ms |
1304 KB |
Output is correct |
13 |
Correct |
1 ms |
1304 KB |
Output is correct |
14 |
Correct |
1 ms |
1308 KB |
Output is correct |
15 |
Correct |
1 ms |
1308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
4480 KB |
Output is correct |
2 |
Correct |
16 ms |
4368 KB |
Output is correct |
3 |
Partially correct |
18 ms |
4696 KB |
Partially correct |
4 |
Partially correct |
10 ms |
3040 KB |
Partially correct |
5 |
Correct |
13 ms |
3808 KB |
Output is correct |
6 |
Correct |
11 ms |
3548 KB |
Output is correct |
7 |
Correct |
10 ms |
3552 KB |
Output is correct |
8 |
Correct |
10 ms |
3288 KB |
Output is correct |
9 |
Correct |
12 ms |
3728 KB |
Output is correct |
10 |
Correct |
9 ms |
3396 KB |
Output is correct |
11 |
Correct |
9 ms |
3388 KB |
Output is correct |
12 |
Partially correct |
9 ms |
3104 KB |
Partially correct |
13 |
Correct |
9 ms |
3104 KB |
Output is correct |
14 |
Correct |
9 ms |
3120 KB |
Output is correct |
15 |
Correct |
9 ms |
3136 KB |
Output is correct |
16 |
Correct |
9 ms |
3128 KB |
Output is correct |
17 |
Partially correct |
10 ms |
3392 KB |
Partially correct |
18 |
Correct |
9 ms |
3140 KB |
Output is correct |
19 |
Correct |
12 ms |
3396 KB |
Output is correct |
20 |
Incorrect |
9 ms |
3640 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
4440 KB |
Output is correct |
2 |
Correct |
17 ms |
4584 KB |
Output is correct |
3 |
Incorrect |
17 ms |
4456 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |