#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;
if(ord[poz[P]]!=P)
return -1;
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]);
}
//return -1;
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;
}
V = Move(ord[i-1]);
}
return rez;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1300 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
4896 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1296 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
4976 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
4924 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |