이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Joi.h"
#define DIM 1010
using namespace std;
static vector <int> L[DIM];
static int viz[DIM],val[DIM],idx,n;
/*void MessageBoard (int x, int y){
return;
}
*/
void dfs (int nod){
viz[nod] = 1;
val[nod] = (++idx) % 60; /// ce bit ii atribui
for (auto vecin : L[nod])
if (!viz[vecin])
dfs (vecin);
}
void Joi (int _n, int m, int a[], int b[], long long x, int useless){
n = _n;
for (int i=0;i<m;i++){
a[i]++, b[i]++;
L[a[i]].push_back(b[i]);
L[b[i]].push_back(a[i]);
}
memset (viz,0,sizeof viz);
memset (val,0,sizeof val);
idx = -1;
dfs (1);
for (int i=1;i<=n;i++){
int bit = val[i];
if (x & (1LL<<bit))
MessageBoard(i-1,1);
else MessageBoard(i-1,0);
}
}
/*
int main (){
ifstream cin ("date.in");
ofstream cout ("date.out");
int n,m,x,i,a[100],b[100];
cin>>n>>m>>x;
for (i=0;i<m;i++)
cin>>a[i]>>b[i];
Joi(n,m,a,b,x,1);
for (i=1;i<=n;i++)
cout<<val[i];
return 0;
}*/
#include <bits/stdc++.h>
#include "Ioi.h"
#define DIM 1010
using namespace std;
static vector <int> L[DIM],edg[DIM];
static int viz[DIM],val[DIM],fth[DIM],s[DIM],f[70],idx,n,cnt;
/*int Move (int dest){
//return value[dest+1];
}
*/
void add_edge (int x, int y){
edg[x].push_back(y);
edg[y].push_back(x);
}
void dfs (int nod){
viz[nod] = s[nod] = 1;
val[nod] = (++idx) % 60; /// ce bit ii atribui
for (auto vecin : L[nod])
if (!viz[vecin]){
fth[vecin] = nod;
add_edge (nod,vecin);
dfs (vecin);
s[nod] += s[vecin];
}
}
void dfs2 (int nod, int tata){
if (cnt == 60)
return;
for (auto vecin : edg[nod])
if (vecin != tata){
int ans = Move(vecin);
if (f[val[vecin]] == -1)
cnt++;
f[val[vecin]] = ans;
if (cnt == 60)
return;
dfs2 (vecin,nod);
Move(nod); /// trb sa ma intorc inapoi
}
}
long long Ioi (int _n, int m, int a[], int b[], int start, int val_start, int useless){
n = _n;
for (int i=0;i<m;i++){
a[i]++, b[i]++;
L[a[i]].push_back(b[i]);
L[b[i]].push_back(a[i]);
}
memset (viz,0,sizeof viz);
memset (val,0,sizeof val);
idx = -1;
dfs (1);
memset (f,-1,sizeof f);
start++;
cnt = 0;
if (f[val[start]] == -1){
f[val[start]] = val_start;
cnt = 1;
}
while (s[start] < 60){
start = fth[start];
Move(start);
}
dfs2 (start,0);
long long sol = 0;
for (int i=0;i<60;i++)
if (f[i])
sol += (1LL<<i);
return sol;
}
/*int main (){
ifstream cin ("date.in");
ofstream cout ("date.out");
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |