#include "Joi.h"
#include <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static int idx[maxn], pai[maxn], deep[maxn], cnt, maior;
static vector<int> grafo[maxn], tree[maxn];
void dfs(int x)
{
idx[x] = cnt++;
maior = max(maior, deep[x] + 1);
for(auto v: grafo[x])
{
if(idx[v] != -1) continue;
pai[v] = x;
deep[v] = deep[x] + 1;
tree[x].push_back(v);
tree[v].push_back(x);
dfs(v);
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T)
{
memset(idx, -1, sizeof idx);
for(int i = 0; i < M; i++)
{
grafo[A[i]].push_back(B[i]);
grafo[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) sort(grafo[i].begin(), grafo[i].end());
dfs(0);
if(maior >= 60)
{
for(int i = 0; i < N; i++)
{
deep[i] %= 60;
if(X & (1LL<<deep[i])) MessageBoard(i, 1);
else MessageBoard(i, 0);
}
}
else
{
for(int i = 0; i < N; i++)
{
idx[i] = idx[i] % 60;
if(X & (1LL<<idx[i])) MessageBoard(i, 1);
else MessageBoard(i, 0);
}
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static ll idx2[maxn], pai2[maxn], deep2[maxn], cnt2, maior2, dp[maxn];
static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
static vector<ll> grafo2[maxn], tree2[maxn], euler;
static ll ans = 0;
static set<ll> usados, tem[maxn];
void dfs2(int x)
{
idx2[x] = cnt2++;
euler.push_back(x);
maior2 = max(maior2, deep2[x] + 1);
dp[x] = 0;
for(auto v: grafo2[x])
{
if(idx2[v] != -1) continue;
pai2[v] = x;
deep2[v] = deep2[x] + 1;
tree2[x].push_back(v);
tree2[v].push_back(x);
dfs2(v);
euler.push_back(x);
if(dp[v] + 1 > dp[x]) dp[x] = dp[v] + 1, opt[x] = v;
}
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
memset(idx2, -1, sizeof idx2);
int Vo = V;
for(int i = 0; i < M; i++)
{
grafo2[A[i]].push_back(B[i]);
grafo2[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) sort(grafo2[i].begin(), grafo2[i].end());
dfs2(0);
if(maior2 >= 60)
{
usados.insert(deep2[P] % 60);
if(V) ans += (1LL<< (deep2[P]%60) );
while(P != 0 and usados.size() < 60)
{
ll val = Move(pai2[P]), aux = deep2[pai2[P]]%60;
if(val && !usados.count(aux)) ans += (1LL<< (aux) );
usados.insert(aux);
P = pai2[P];
}
if(usados.size() >= 60) return ans;
while(usados.size() < 60)
{
ll val = Move(opt[P]), aux = deep2[opt[P]]%60;
if(val && !usados.count(aux)) ans += (1LL<< (aux) );
usados.insert(aux);
P = opt[P];
}
return ans;
}
for(int i = 0; i < N; i++) idx2[i] = (idx2[i] % 60);
ll t = 0, save;
for(int i = 0; i < euler.size(); i++)
{
if(euler[i] == P)
{
t = save = i;
break;
}
}
ll pos = 0;
pos |= (1LL<<idx2[P]);
t ++;
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t >= euler.size() - 1) t = 0;
ll x = euler[t];
pos |= (1LL<<idx2[x]);
t ++;
}
//cout<<pos<<" "<<((1LL<<60) - 1LL)<<"\n";
if(pos == ((1LL<<60) - 1LL))
{
if(Vo) ans |= (1LL<<idx2[P]);
t = save + 1;
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t >= euler.size() - 1) t = 0;
ll x = euler[t];
V = Move(x);
if(V) ans |= (1LL<<idx2[x]);
t ++;
}
//cout<<ans<<"\n";
return ans;
}
else
{
//for(auto tt: euler) cout<<tt<<" ";
//cout<<"\n";
if(Vo) ans |= (1LL<<idx2[P]);
t = save - 1;
ll aux = 1LL<<idx2[P];
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t <= 0) t = euler.size() - 1;
ll x = euler[t];
V = Move(x);
aux |= (1LL<<idx2[x]);
if(V) ans |= (1LL<<idx2[x]);
t --;
}
//cout<<aux<<" "<<((1LL<<60) - 1LL)<<"\n";
return ans;
}
}
Compilation message
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:104:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < euler.size(); i++)
~~^~~~~~~~~~~~~~
Ioi.cpp:122:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(t >= euler.size() - 1) t = 0;
~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp:141:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(t >= euler.size() - 1) t = 0;
~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp: At global scope:
Ioi.cpp:12:44: warning: 'save' defined but not used [-Wunused-variable]
static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
^~~~
Ioi.cpp:12:33: warning: 'fim' defined but not used [-Wunused-variable]
static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
^~~
Ioi.cpp:12:22: warning: 'ini' defined but not used [-Wunused-variable]
static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
^~~
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:137:5: warning: 'save' may be used uninitialized in this function [-Wmaybe-uninitialized]
t = save + 1;
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2272 KB |
Output is correct |
2 |
Correct |
7 ms |
3120 KB |
Output is correct |
3 |
Correct |
7 ms |
3280 KB |
Output is correct |
4 |
Correct |
7 ms |
3344 KB |
Output is correct |
5 |
Correct |
7 ms |
3344 KB |
Output is correct |
6 |
Correct |
7 ms |
3344 KB |
Output is correct |
7 |
Correct |
5 ms |
3404 KB |
Output is correct |
8 |
Correct |
7 ms |
3480 KB |
Output is correct |
9 |
Correct |
6 ms |
3592 KB |
Output is correct |
10 |
Correct |
5 ms |
3688 KB |
Output is correct |
11 |
Correct |
11 ms |
3780 KB |
Output is correct |
12 |
Correct |
5 ms |
3872 KB |
Output is correct |
13 |
Correct |
6 ms |
3872 KB |
Output is correct |
14 |
Correct |
7 ms |
3872 KB |
Output is correct |
15 |
Correct |
6 ms |
3872 KB |
Output is correct |
16 |
Correct |
6 ms |
3872 KB |
Output is correct |
17 |
Correct |
6 ms |
3872 KB |
Output is correct |
18 |
Correct |
6 ms |
3872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
7336 KB |
Output is correct |
2 |
Correct |
40 ms |
8560 KB |
Output is correct |
3 |
Correct |
43 ms |
8560 KB |
Output is correct |
4 |
Correct |
27 ms |
8560 KB |
Output is correct |
5 |
Correct |
24 ms |
8560 KB |
Output is correct |
6 |
Correct |
27 ms |
8560 KB |
Output is correct |
7 |
Correct |
25 ms |
8560 KB |
Output is correct |
8 |
Correct |
24 ms |
8560 KB |
Output is correct |
9 |
Correct |
25 ms |
8560 KB |
Output is correct |
10 |
Correct |
23 ms |
8560 KB |
Output is correct |
11 |
Correct |
23 ms |
8560 KB |
Output is correct |
12 |
Correct |
26 ms |
8560 KB |
Output is correct |
13 |
Correct |
26 ms |
8560 KB |
Output is correct |
14 |
Correct |
26 ms |
8560 KB |
Output is correct |
15 |
Correct |
24 ms |
8560 KB |
Output is correct |
16 |
Correct |
25 ms |
8560 KB |
Output is correct |
17 |
Correct |
25 ms |
8560 KB |
Output is correct |
18 |
Correct |
26 ms |
8616 KB |
Output is correct |
19 |
Correct |
28 ms |
8784 KB |
Output is correct |
20 |
Correct |
28 ms |
9380 KB |
Output is correct |
21 |
Correct |
22 ms |
9996 KB |
Output is correct |
22 |
Correct |
27 ms |
10128 KB |
Output is correct |
23 |
Correct |
31 ms |
10160 KB |
Output is correct |
24 |
Correct |
43 ms |
10276 KB |
Output is correct |
25 |
Correct |
38 ms |
10372 KB |
Output is correct |
26 |
Correct |
55 ms |
10584 KB |
Output is correct |
27 |
Correct |
41 ms |
10868 KB |
Output is correct |
28 |
Correct |
31 ms |
11048 KB |
Output is correct |
29 |
Correct |
27 ms |
11216 KB |
Output is correct |
30 |
Correct |
34 ms |
11288 KB |
Output is correct |
31 |
Correct |
8 ms |
11288 KB |
Output is correct |
32 |
Incorrect |
6 ms |
11288 KB |
Wrong Answer [7] |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
11288 KB |
Output is correct |
2 |
Correct |
5 ms |
11288 KB |
Output is correct |
3 |
Correct |
6 ms |
11288 KB |
Output is correct |
4 |
Correct |
9 ms |
11288 KB |
Output is correct |
5 |
Correct |
8 ms |
11288 KB |
Output is correct |
6 |
Correct |
7 ms |
11288 KB |
Output is correct |
7 |
Correct |
8 ms |
11288 KB |
Output is correct |
8 |
Correct |
9 ms |
11288 KB |
Output is correct |
9 |
Correct |
22 ms |
11672 KB |
Output is correct |
10 |
Correct |
27 ms |
12056 KB |
Output is correct |
11 |
Correct |
20 ms |
12056 KB |
Output is correct |
12 |
Correct |
5 ms |
12056 KB |
Output is correct |
13 |
Correct |
6 ms |
12056 KB |
Output is correct |
14 |
Correct |
6 ms |
12056 KB |
Output is correct |
15 |
Correct |
4 ms |
12056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
12304 KB |
Output is correct |
2 |
Correct |
56 ms |
12552 KB |
Output is correct |
3 |
Correct |
45 ms |
12556 KB |
Output is correct |
4 |
Correct |
28 ms |
12560 KB |
Output is correct |
5 |
Correct |
32 ms |
12560 KB |
Output is correct |
6 |
Correct |
25 ms |
12560 KB |
Output is correct |
7 |
Correct |
26 ms |
12560 KB |
Output is correct |
8 |
Correct |
32 ms |
12560 KB |
Output is correct |
9 |
Correct |
31 ms |
12560 KB |
Output is correct |
10 |
Correct |
25 ms |
12560 KB |
Output is correct |
11 |
Correct |
27 ms |
12560 KB |
Output is correct |
12 |
Correct |
25 ms |
12560 KB |
Output is correct |
13 |
Correct |
25 ms |
12560 KB |
Output is correct |
14 |
Correct |
31 ms |
12560 KB |
Output is correct |
15 |
Correct |
26 ms |
12560 KB |
Output is correct |
16 |
Correct |
30 ms |
12560 KB |
Output is correct |
17 |
Correct |
37 ms |
12560 KB |
Output is correct |
18 |
Correct |
28 ms |
12560 KB |
Output is correct |
19 |
Correct |
28 ms |
12560 KB |
Output is correct |
20 |
Correct |
23 ms |
12560 KB |
Output is correct |
21 |
Correct |
20 ms |
12560 KB |
Output is correct |
22 |
Correct |
30 ms |
12560 KB |
Output is correct |
23 |
Correct |
26 ms |
12560 KB |
Output is correct |
24 |
Correct |
43 ms |
12560 KB |
Output is correct |
25 |
Correct |
30 ms |
12560 KB |
Output is correct |
26 |
Correct |
28 ms |
12560 KB |
Output is correct |
27 |
Correct |
27 ms |
12816 KB |
Output is correct |
28 |
Correct |
26 ms |
13072 KB |
Output is correct |
29 |
Correct |
27 ms |
13072 KB |
Output is correct |
30 |
Correct |
34 ms |
13108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
13832 KB |
Output is correct |
2 |
Correct |
55 ms |
14520 KB |
Output is correct |
3 |
Correct |
39 ms |
14520 KB |
Output is correct |
4 |
Correct |
25 ms |
14520 KB |
Output is correct |
5 |
Correct |
25 ms |
14520 KB |
Output is correct |
6 |
Correct |
31 ms |
14520 KB |
Output is correct |
7 |
Correct |
34 ms |
14520 KB |
Output is correct |
8 |
Correct |
26 ms |
14520 KB |
Output is correct |
9 |
Correct |
33 ms |
14520 KB |
Output is correct |
10 |
Correct |
25 ms |
14520 KB |
Output is correct |
11 |
Correct |
24 ms |
14520 KB |
Output is correct |
12 |
Correct |
23 ms |
14520 KB |
Output is correct |
13 |
Correct |
30 ms |
14520 KB |
Output is correct |
14 |
Correct |
24 ms |
14524 KB |
Output is correct |
15 |
Correct |
26 ms |
14608 KB |
Output is correct |
16 |
Correct |
24 ms |
14688 KB |
Output is correct |
17 |
Correct |
26 ms |
14880 KB |
Output is correct |
18 |
Correct |
24 ms |
15192 KB |
Output is correct |
19 |
Correct |
28 ms |
15516 KB |
Output is correct |
20 |
Correct |
24 ms |
16220 KB |
Output is correct |
21 |
Correct |
20 ms |
16796 KB |
Output is correct |
22 |
Correct |
24 ms |
16872 KB |
Output is correct |
23 |
Correct |
27 ms |
16872 KB |
Output is correct |
24 |
Correct |
26 ms |
16924 KB |
Output is correct |
25 |
Correct |
27 ms |
17136 KB |
Output is correct |
26 |
Correct |
26 ms |
17364 KB |
Output is correct |
27 |
Correct |
27 ms |
17620 KB |
Output is correct |
28 |
Correct |
28 ms |
17904 KB |
Output is correct |
29 |
Correct |
26 ms |
18028 KB |
Output is correct |
30 |
Correct |
34 ms |
18072 KB |
Output is correct |
31 |
Correct |
7 ms |
18088 KB |
Output is correct |
32 |
Correct |
6 ms |
18088 KB |
Output is correct |
33 |
Correct |
6 ms |
18088 KB |
Output is correct |
34 |
Correct |
6 ms |
18088 KB |
Output is correct |
35 |
Correct |
6 ms |
18088 KB |
Output is correct |
36 |
Correct |
7 ms |
18088 KB |
Output is correct |
37 |
Correct |
7 ms |
18088 KB |
Output is correct |
38 |
Correct |
5 ms |
18088 KB |
Output is correct |
39 |
Correct |
6 ms |
18088 KB |
Output is correct |
40 |
Correct |
6 ms |
18088 KB |
Output is correct |
41 |
Correct |
5 ms |
18088 KB |
Output is correct |
42 |
Correct |
5 ms |
18088 KB |
Output is correct |