#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static void dfs(int nod)
{
visited[nod]=1;
sort(con[nod].begin(),con[nod].end());
ord.push_back(nod);
for(auto adj:con[nod])
{
if(!visited[adj])
{
dfs(adj);
ord.push_back(nod);
}
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
ord.clear();
for(int i=0;i<N;i++)
{
visited[i]=0;
con[i].clear();
done[i]=0;
}
for(int i=0;i<M;i++)
{
con[A[i]].push_back(B[i]);
con[B[i]].push_back(A[i]);
}
dfs(0);
int cnt=0;
for(int i=0;i<(int)ord.size();i++)
{
if(!done[ord[i]])
{
if(((1LL<<cnt)&X))
MessageBoard(ord[i],1);
else
MessageBoard(ord[i],0);
cnt++;
done[ord[i]]=1;
}
}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
static bool visited[10005];
static vector<int> ord;
static vector<int> con[10005];
static bool done[10005];
static int p[50005];
static int poz[10005];
static int fr[65];
static int care[10005];
static void dfs(int nod)
{
visited[nod]=1;
sort(con[nod].begin(),con[nod].end());
poz[nod]=ord.size();
ord.push_back(nod);
for(auto adj:con[nod])
{
if(!visited[adj])
{
dfs(adj);
ord.push_back(nod);
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
ord.clear();
for(int i=0;i<N;i++)
{
visited[i]=0;
con[i].clear();
done[i]=0;
}
for(int i=0;i<60;i++)
fr[i]=0;
for(int i=0;i<M;i++)
{
con[A[i]].push_back(B[i]);
con[B[i]].push_back(A[i]);
}
dfs(0);
int cnt=0;
for(int i=0;i<(int)ord.size();i++)
{
if(!done[ord[i]])
{
care[ord[i]]=cnt;
cnt=(cnt+1)%60;
done[ord[i]]=1;
}
p[i]=care[ord[i]];
}
long long rez=0;
int cate=0;
for(int i=poz[P];i<(int)ord.size();i++)
{
if(fr[p[i]]==0)
{
rez += V * (1LL<<(p[i]));
fr[p[i]]=1;
cate++;
if(cate==60)
return rez;
}
if(i+1<(int)ord.size()) V = Move(ord[i+1]);
}
while(1)
N=0;
for(int i=(int)ord.size()-1;i>=0;i--)
{
if(fr[p[i]]==0)
{
rez += V * (1LL<<(p[i]));
fr[p[i]]=1;
cate++;
if(cate==60)
return rez;
}
if(i==0)
{
while(1)
i=1;
}
V = Move(ord[i-1]);
}
return rez;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1292 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
4964 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1308 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
4968 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
4892 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |