#include "Joi.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
static const int nmax=20005;
static vector<int> v[nmax];
static int viz[nmax],w[nmax],tt[nmax];
static long long et[nmax];
static int i,j,nr;
static void dfs(int x)
{
viz[x]=1;et[x]=++nr;et[x]%=60;
w[x]=1;
for(int i=0;i<v[x].size();i++)
if(!viz[v[x][i]])
{
tt[v[x][i]]=x;
dfs(v[x][i]);
w[x]+=w[v[x][i]];
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for(i=0;i<M;i++)
{
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
for(i=0;i<N;i++)
sort(v[i].begin(),v[i].end());
dfs(0);
for(int i = 0; i < N; i++){
MessageBoard(i, (((1LL<<et[i])&X)!=0));
}
}
#include "Ioi.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
static const int nmax=20005;
static vector<int> v[nmax];
static int viz[nmax],w[nmax],tt[nmax];
static long long et[nmax];
static int act[100];
static int i,j,nr;
static int visited;
static void dfs(int x)
{
viz[x]=1;et[x]=++nr;et[x]%=60;
w[x]=1;
for(int i=0;i<v[x].size();i++)
if(!viz[v[x][i]])
{
tt[v[x][i]]=x;
dfs(v[x][i]);
w[x]+=w[v[x][i]];
}
}
static void dfs2(int x)
{
visited++;
for(int i=0;i<v[x].size()&&visited<60;i++)
if(w[v[x][i]]<w[x])
{
act[et[v[x][i]]]=Move(v[x][i]);
dfs2(v[x][i]);
}
if(visited<60)
int bla=Move(tt[x]);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(i=0;i<M;i++)
{
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
for(i=0;i<N;i++)
sort(v[i].begin(),v[i].end());
dfs(0);
int rt=P;
int xx=V;
while(w[rt]<60)
{
xx=Move(tt[rt]);
rt=tt[rt];
}
act[et[rt]]=xx;
dfs2(rt);
long long ans=0;
for(i=0;i<60;i++)
if(act[i])
ans+=(1LL<<i);
return ans;
}
Compilation message
Joi.cpp: In function 'void dfs(int)':
Joi.cpp:15:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
Joi.cpp: At global scope:
Joi.cpp:10:14: warning: 'j' defined but not used [-Wunused-variable]
static int i,j,nr;
^
Ioi.cpp: In function 'void dfs(int)':
Ioi.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
Ioi.cpp: In function 'void dfs2(int)':
Ioi.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v[x].size()&&visited<60;i++)
~^~~~~~~~~~~~
Ioi.cpp:35:10: warning: unused variable 'bla' [-Wunused-variable]
int bla=Move(tt[x]);
^~~
Ioi.cpp: At global scope:
Ioi.cpp:11:14: warning: 'j' defined but not used [-Wunused-variable]
static int i,j,nr;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1800 KB |
Output is correct |
2 |
Correct |
6 ms |
1928 KB |
Output is correct |
3 |
Correct |
6 ms |
2024 KB |
Output is correct |
4 |
Correct |
7 ms |
1664 KB |
Output is correct |
5 |
Correct |
5 ms |
1800 KB |
Output is correct |
6 |
Correct |
6 ms |
1664 KB |
Output is correct |
7 |
Correct |
6 ms |
1796 KB |
Output is correct |
8 |
Correct |
5 ms |
1924 KB |
Output is correct |
9 |
Correct |
5 ms |
1668 KB |
Output is correct |
10 |
Correct |
5 ms |
1664 KB |
Output is correct |
11 |
Correct |
10 ms |
2208 KB |
Output is correct |
12 |
Correct |
7 ms |
1800 KB |
Output is correct |
13 |
Correct |
6 ms |
1896 KB |
Output is correct |
14 |
Correct |
4 ms |
2048 KB |
Output is correct |
15 |
Correct |
6 ms |
1904 KB |
Output is correct |
16 |
Correct |
7 ms |
1896 KB |
Output is correct |
17 |
Correct |
3 ms |
1668 KB |
Output is correct |
18 |
Correct |
5 ms |
1668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4820 KB |
Output is correct |
2 |
Correct |
31 ms |
4776 KB |
Output is correct |
3 |
Correct |
39 ms |
4820 KB |
Output is correct |
4 |
Correct |
20 ms |
3608 KB |
Output is correct |
5 |
Correct |
19 ms |
4060 KB |
Output is correct |
6 |
Correct |
20 ms |
3976 KB |
Output is correct |
7 |
Correct |
20 ms |
3968 KB |
Output is correct |
8 |
Correct |
24 ms |
3992 KB |
Output is correct |
9 |
Correct |
20 ms |
4076 KB |
Output is correct |
10 |
Correct |
22 ms |
3800 KB |
Output is correct |
11 |
Correct |
23 ms |
3776 KB |
Output is correct |
12 |
Correct |
20 ms |
3484 KB |
Output is correct |
13 |
Correct |
19 ms |
3464 KB |
Output is correct |
14 |
Correct |
24 ms |
3716 KB |
Output is correct |
15 |
Correct |
19 ms |
3608 KB |
Output is correct |
16 |
Correct |
26 ms |
3688 KB |
Output is correct |
17 |
Correct |
25 ms |
3608 KB |
Output is correct |
18 |
Correct |
19 ms |
3616 KB |
Output is correct |
19 |
Correct |
19 ms |
3604 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
17 ms |
4000 KB |
Output is correct |
22 |
Correct |
23 ms |
3744 KB |
Output is correct |
23 |
Correct |
23 ms |
4000 KB |
Output is correct |
24 |
Correct |
25 ms |
3856 KB |
Output is correct |
25 |
Correct |
20 ms |
4000 KB |
Output is correct |
26 |
Correct |
20 ms |
4128 KB |
Output is correct |
27 |
Correct |
20 ms |
4000 KB |
Output is correct |
28 |
Correct |
24 ms |
3992 KB |
Output is correct |
29 |
Correct |
28 ms |
3772 KB |
Output is correct |
30 |
Correct |
22 ms |
3860 KB |
Output is correct |
31 |
Correct |
4 ms |
1900 KB |
Output is correct |
32 |
Correct |
4 ms |
1896 KB |
Output is correct |
33 |
Correct |
6 ms |
1932 KB |
Output is correct |
34 |
Correct |
7 ms |
1928 KB |
Output is correct |
35 |
Correct |
6 ms |
1904 KB |
Output is correct |
36 |
Correct |
6 ms |
1800 KB |
Output is correct |
37 |
Correct |
5 ms |
2040 KB |
Output is correct |
38 |
Correct |
5 ms |
1664 KB |
Output is correct |
39 |
Correct |
5 ms |
1664 KB |
Output is correct |
40 |
Correct |
6 ms |
1904 KB |
Output is correct |
41 |
Correct |
6 ms |
1904 KB |
Output is correct |
42 |
Correct |
5 ms |
1692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1664 KB |
Output is correct |
2 |
Correct |
6 ms |
1908 KB |
Output is correct |
3 |
Correct |
6 ms |
1900 KB |
Output is correct |
4 |
Correct |
7 ms |
2084 KB |
Output is correct |
5 |
Correct |
8 ms |
2076 KB |
Output is correct |
6 |
Correct |
7 ms |
2212 KB |
Output is correct |
7 |
Correct |
7 ms |
2212 KB |
Output is correct |
8 |
Correct |
7 ms |
2268 KB |
Output is correct |
9 |
Correct |
15 ms |
4416 KB |
Output is correct |
10 |
Correct |
18 ms |
4408 KB |
Output is correct |
11 |
Correct |
16 ms |
4160 KB |
Output is correct |
12 |
Correct |
5 ms |
1912 KB |
Output is correct |
13 |
Correct |
5 ms |
1800 KB |
Output is correct |
14 |
Correct |
6 ms |
1800 KB |
Output is correct |
15 |
Correct |
5 ms |
1800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4924 KB |
Output is correct |
2 |
Correct |
30 ms |
4784 KB |
Output is correct |
3 |
Correct |
31 ms |
4820 KB |
Output is correct |
4 |
Correct |
23 ms |
3744 KB |
Output is correct |
5 |
Partially correct |
22 ms |
4372 KB |
Partially correct |
6 |
Correct |
20 ms |
4080 KB |
Output is correct |
7 |
Correct |
19 ms |
4080 KB |
Output is correct |
8 |
Correct |
25 ms |
3864 KB |
Output is correct |
9 |
Correct |
22 ms |
3872 KB |
Output is correct |
10 |
Correct |
18 ms |
3740 KB |
Output is correct |
11 |
Correct |
24 ms |
3748 KB |
Output is correct |
12 |
Correct |
18 ms |
3456 KB |
Output is correct |
13 |
Correct |
19 ms |
3464 KB |
Output is correct |
14 |
Correct |
17 ms |
3716 KB |
Output is correct |
15 |
Correct |
20 ms |
3688 KB |
Output is correct |
16 |
Correct |
19 ms |
3616 KB |
Output is correct |
17 |
Correct |
20 ms |
3608 KB |
Output is correct |
18 |
Correct |
19 ms |
3804 KB |
Output is correct |
19 |
Correct |
18 ms |
3680 KB |
Output is correct |
20 |
Correct |
16 ms |
4128 KB |
Output is correct |
21 |
Correct |
15 ms |
4056 KB |
Output is correct |
22 |
Correct |
22 ms |
4084 KB |
Output is correct |
23 |
Correct |
24 ms |
3864 KB |
Output is correct |
24 |
Correct |
25 ms |
3872 KB |
Output is correct |
25 |
Correct |
19 ms |
4240 KB |
Output is correct |
26 |
Correct |
20 ms |
3992 KB |
Output is correct |
27 |
Correct |
23 ms |
4128 KB |
Output is correct |
28 |
Correct |
25 ms |
3988 KB |
Output is correct |
29 |
Correct |
19 ms |
3780 KB |
Output is correct |
30 |
Correct |
20 ms |
3860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
4836 KB |
Output is correct |
2 |
Correct |
31 ms |
4828 KB |
Output is correct |
3 |
Correct |
33 ms |
5140 KB |
Output is correct |
4 |
Correct |
20 ms |
3808 KB |
Output is correct |
5 |
Incorrect |
20 ms |
4376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |