#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
#define X first
#define Y second
#define pb push_back
#define MAXN 20100
namespace JOI {
int n, m;
int a[MAXN], b[MAXN];
ll x;
int t;
vector<int> g[MAXN];
int tt = 0;
int bio[MAXN];
int usao[MAXN];
void dfs(int cv, int rod)
{
if (bio[cv]) return;
bio[cv] = 1;
usao[cv] = tt;
tt++;
MessageBoard(cv, !!(x & (1LL << ll(usao[cv] % 60))));
for (int i: g[cv]) {
if (rod != i) {
dfs(i, cv);
}
}
}
}
using namespace JOI;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
n = N; m = M; x = X; t = T;
for(int i = 0; i < N; i++){
//MessageBoard(i, 0);
}
for (int i = 0; i < m; i++) {
a[i] = A[i];
b[i] = B[i];
g[a[i]].pb(b[i]);
g[b[i]].pb(a[i]);
}
dfs(0, -1);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
#define X first
#define Y second
#define pb push_back
#define MAXN 20100
namespace IOI {
int n, m;
int a[MAXN], b[MAXN], par[MAXN];
int p, v;
int t;
vector<int> g[MAXN];
int tt = 0;
int bio[MAXN];
int usao[MAXN];
ll reza = 0LL;
int done[100], cnt = 0;
int calls = 0;
void dfs(int cv, int rod)
{
if (bio[cv]) return;
bio[cv] = 1;
usao[cv] = tt;
tt++;
par[cv] = rod;
for (int i: g[cv]) {
if (rod != i) {
dfs(i, cv);
}
}
}
void dfs2(int cv, int msg, int isrt)
{ if (calls > 120 && t > 3) return;
bio[cv] = 1;
int cu = usao[cv] % 60;
if (!done[cu]) {
cnt++;
done[cu] = 1;
reza |= ll(msg) * (1LL << ll(cu));
}
if (cnt == 60) return; if (calls > 120 && t > 3) return;
for (int i: g[cv]) {
if (i == par[cv]) continue;
if (bio[i]) continue;
calls++; if (calls > 120 && t > 3) return;
int nx = Move(i);
dfs2(i, nx, 0); if (calls > 120 && t > 3) return;
if (cnt == 60) return;
}
if (par[cv] != -1
//&& isrt
)
{
calls++; if (calls > 120 && t > 3) return;
int nx = Move(par[cv]);
if (isrt) dfs2(par[cv], nx, 1);
if (calls > 120 && t > 3) return;
}
}
}
using namespace IOI;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
n = N; m = M; p = P; v = V; t = T;
for (int i = 0; i < m; i++) {
a[i] = A[i];
b[i] = B[i];
g[a[i]].pb(b[i]);
g[b[i]].pb(a[i]);
}
dfs(0, -1);
memset(bio, 0, sizeof bio);
dfs2(p, v, 1);
//return 0LL;
return reza;
}
Compilation message
Ioi.cpp: In function 'void IOI::dfs2(int, int, int)':
Ioi.cpp:49:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
49 | if (cnt == 60) return; if (calls > 120 && t > 3) return;
| ^~
Ioi.cpp:49:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
49 | if (cnt == 60) return; if (calls > 120 && t > 3) return;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1956 KB |
Output is correct |
2 |
Correct |
2 ms |
1796 KB |
Output is correct |
3 |
Correct |
2 ms |
1932 KB |
Output is correct |
4 |
Correct |
2 ms |
1796 KB |
Output is correct |
5 |
Correct |
2 ms |
1796 KB |
Output is correct |
6 |
Correct |
2 ms |
1796 KB |
Output is correct |
7 |
Correct |
2 ms |
1932 KB |
Output is correct |
8 |
Correct |
2 ms |
2052 KB |
Output is correct |
9 |
Correct |
2 ms |
2056 KB |
Output is correct |
10 |
Correct |
2 ms |
1668 KB |
Output is correct |
11 |
Correct |
6 ms |
2304 KB |
Output is correct |
12 |
Correct |
2 ms |
1816 KB |
Output is correct |
13 |
Correct |
2 ms |
2316 KB |
Output is correct |
14 |
Correct |
2 ms |
2048 KB |
Output is correct |
15 |
Correct |
2 ms |
1932 KB |
Output is correct |
16 |
Correct |
2 ms |
2052 KB |
Output is correct |
17 |
Correct |
2 ms |
1932 KB |
Output is correct |
18 |
Correct |
2 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
5168 KB |
Output is correct |
2 |
Correct |
31 ms |
5164 KB |
Output is correct |
3 |
Correct |
31 ms |
5116 KB |
Output is correct |
4 |
Correct |
17 ms |
3568 KB |
Output is correct |
5 |
Correct |
18 ms |
4148 KB |
Output is correct |
6 |
Correct |
19 ms |
3788 KB |
Output is correct |
7 |
Correct |
18 ms |
3832 KB |
Output is correct |
8 |
Correct |
17 ms |
4172 KB |
Output is correct |
9 |
Correct |
17 ms |
3864 KB |
Output is correct |
10 |
Correct |
16 ms |
3796 KB |
Output is correct |
11 |
Correct |
18 ms |
3672 KB |
Output is correct |
12 |
Correct |
16 ms |
3400 KB |
Output is correct |
13 |
Correct |
15 ms |
3392 KB |
Output is correct |
14 |
Correct |
17 ms |
3396 KB |
Output is correct |
15 |
Correct |
19 ms |
3728 KB |
Output is correct |
16 |
Correct |
18 ms |
3568 KB |
Output is correct |
17 |
Correct |
17 ms |
3572 KB |
Output is correct |
18 |
Correct |
19 ms |
3572 KB |
Output is correct |
19 |
Correct |
17 ms |
3532 KB |
Output is correct |
20 |
Correct |
15 ms |
4044 KB |
Output is correct |
21 |
Correct |
15 ms |
3916 KB |
Output is correct |
22 |
Correct |
17 ms |
3660 KB |
Output is correct |
23 |
Correct |
18 ms |
3916 KB |
Output is correct |
24 |
Correct |
17 ms |
3960 KB |
Output is correct |
25 |
Correct |
18 ms |
3944 KB |
Output is correct |
26 |
Correct |
19 ms |
4044 KB |
Output is correct |
27 |
Correct |
17 ms |
3924 KB |
Output is correct |
28 |
Correct |
17 ms |
4044 KB |
Output is correct |
29 |
Correct |
16 ms |
4008 KB |
Output is correct |
30 |
Correct |
18 ms |
3928 KB |
Output is correct |
31 |
Correct |
2 ms |
1808 KB |
Output is correct |
32 |
Correct |
2 ms |
1804 KB |
Output is correct |
33 |
Correct |
2 ms |
1932 KB |
Output is correct |
34 |
Correct |
2 ms |
1796 KB |
Output is correct |
35 |
Correct |
2 ms |
1808 KB |
Output is correct |
36 |
Correct |
2 ms |
1796 KB |
Output is correct |
37 |
Correct |
2 ms |
1812 KB |
Output is correct |
38 |
Correct |
2 ms |
1796 KB |
Output is correct |
39 |
Correct |
2 ms |
1808 KB |
Output is correct |
40 |
Correct |
2 ms |
1808 KB |
Output is correct |
41 |
Correct |
2 ms |
1800 KB |
Output is correct |
42 |
Correct |
2 ms |
1804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1796 KB |
Output is correct |
2 |
Correct |
2 ms |
2064 KB |
Output is correct |
3 |
Correct |
2 ms |
1820 KB |
Output is correct |
4 |
Correct |
4 ms |
2212 KB |
Output is correct |
5 |
Correct |
4 ms |
2340 KB |
Output is correct |
6 |
Correct |
4 ms |
2212 KB |
Output is correct |
7 |
Correct |
4 ms |
2392 KB |
Output is correct |
8 |
Correct |
4 ms |
2212 KB |
Output is correct |
9 |
Correct |
15 ms |
4668 KB |
Output is correct |
10 |
Correct |
15 ms |
4664 KB |
Output is correct |
11 |
Correct |
15 ms |
4664 KB |
Output is correct |
12 |
Correct |
2 ms |
1796 KB |
Output is correct |
13 |
Correct |
2 ms |
1816 KB |
Output is correct |
14 |
Correct |
2 ms |
1828 KB |
Output is correct |
15 |
Correct |
2 ms |
1796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
5096 KB |
Output is correct |
2 |
Correct |
28 ms |
5152 KB |
Output is correct |
3 |
Correct |
31 ms |
5124 KB |
Output is correct |
4 |
Correct |
17 ms |
3544 KB |
Output is correct |
5 |
Correct |
18 ms |
4484 KB |
Output is correct |
6 |
Correct |
17 ms |
3916 KB |
Output is correct |
7 |
Correct |
18 ms |
3920 KB |
Output is correct |
8 |
Correct |
19 ms |
3660 KB |
Output is correct |
9 |
Correct |
17 ms |
3832 KB |
Output is correct |
10 |
Correct |
16 ms |
3660 KB |
Output is correct |
11 |
Correct |
16 ms |
3808 KB |
Output is correct |
12 |
Correct |
15 ms |
3648 KB |
Output is correct |
13 |
Correct |
15 ms |
3420 KB |
Output is correct |
14 |
Correct |
16 ms |
3612 KB |
Output is correct |
15 |
Correct |
17 ms |
3532 KB |
Output is correct |
16 |
Correct |
17 ms |
3532 KB |
Output is correct |
17 |
Correct |
19 ms |
3700 KB |
Output is correct |
18 |
Correct |
19 ms |
3572 KB |
Output is correct |
19 |
Correct |
18 ms |
3748 KB |
Output is correct |
20 |
Correct |
15 ms |
4132 KB |
Output is correct |
21 |
Correct |
15 ms |
4132 KB |
Output is correct |
22 |
Correct |
18 ms |
4132 KB |
Output is correct |
23 |
Correct |
18 ms |
4200 KB |
Output is correct |
24 |
Correct |
18 ms |
4212 KB |
Output is correct |
25 |
Correct |
18 ms |
4180 KB |
Output is correct |
26 |
Correct |
18 ms |
4132 KB |
Output is correct |
27 |
Correct |
19 ms |
4140 KB |
Output is correct |
28 |
Correct |
17 ms |
4004 KB |
Output is correct |
29 |
Correct |
16 ms |
3892 KB |
Output is correct |
30 |
Correct |
17 ms |
4004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
5340 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |