#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
int cnt;
int rec[10005];
bool vis[10005];
long long now,mul;
vector<int> a;
vector<int> from[10005];
queue<int> q;
int sssp(int P) {
int i,x,res;
memset(vis,0,sizeof(vis));
vis[P] = 1;
q.push(P);
while(!q.empty()) {
x = q.front(); q.pop();
for(i=0;i<from[x].size();i++) {
if(!vis[from[x][i]]) {
vis[from[x][i]] = 1;
rec[from[x][i]] = x;
q.push(from[x][i]);
}
}
}
x = 0;
a.clear();
while(x!=P) {
a.push_back(x);
x = rec[x];
}
for(i=a.size()-1;i>=0;i--) res = Move(a[i]), cnt++;
return res;
}
void dfs(int x,int last) {
int i;
if(cnt>=180) return ;
vis[x] = 1;
for(i=0;i<from[x].size();i++) {
if(!vis[from[x][i]]) {
now += mul*Move(from[x][i]);
cnt++;
mul *= 2;
dfs(from[x][i],x);
}
}
Move(last);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
int i;
//Init graph
for(i=0;i<N;i++) from[i].clear();
for(i=0;i<M;i++) from[A[i]].push_back(B[i]), from[B[i]].push_back(A[i]);
for(i=0;i<N;i++) sort(&from[i][0],&from[i][from[i].size()]);
//Move to attr 0
now = V;
if(P!=0) now = sssp(P);
//DFS from attr 0
memset(vis,0,sizeof(vis));
mul = 2;
dfs(0,-1);
//Answer
return now;
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
int cnt;
int rec[10005];
bool vis[10005];
long long now,mul;
vector<int> a;
vector<int> from[10005];
queue<int> q;
int sssp(int P) {
int i,x,res;
memset(vis,0,sizeof(vis));
vis[P] = 1;
q.push(P);
while(!q.empty()) {
x = q.front(); q.pop();
for(i=0;i<from[x].size();i++) {
if(!vis[from[x][i]]) {
vis[from[x][i]] = 1;
rec[from[x][i]] = x;
q.push(from[x][i]);
}
}
}
x = 0;
a.clear();
while(x!=P) {
a.push_back(x);
x = rec[x];
}
for(i=a.size()-1;i>=0;i--) res = Move(a[i]), cnt++;
return res;
}
void dfs(int x,int last) {
int i;
if(cnt>=180) return ;
vis[x] = 1;
for(i=0;i<from[x].size();i++) {
if(!vis[from[x][i]]) {
now += mul*Move(from[x][i]);
cnt++;
mul *= 2;
dfs(from[x][i],x);
}
}
Move(last);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
int i;
//Init graph
for(i=0;i<N;i++) from[i].clear();
for(i=0;i<M;i++) from[A[i]].push_back(B[i]), from[B[i]].push_back(A[i]);
for(i=0;i<N;i++) sort(&from[i][0],&from[i][from[i].size()]);
//Move to attr 0
now = V;
if(P!=0) now = sssp(P);
//DFS from attr 0
memset(vis,0,sizeof(vis));
mul = 2;
dfs(0,-1);
//Answer
return now;
}
Compilation message
Joi.cpp: In function 'int sssp(int)':
Joi.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<from[x].size();i++) {
^
Joi.cpp:32:47: error: 'Move' was not declared in this scope
for(i=a.size()-1;i>=0;i--) res = Move(a[i]), cnt++;
^
Joi.cpp: In function 'void dfs(int, int)':
Joi.cpp:39:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<from[x].size();i++) {
^
Joi.cpp:41:39: error: 'Move' was not declared in this scope
now += mul*Move(from[x][i]);
^
Joi.cpp:47:14: error: 'Move' was not declared in this scope
Move(last);
^
Ioi.cpp: In function 'int sssp(int)':
Ioi.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<from[x].size();i++) {
^
Ioi.cpp: In function 'void dfs(int, int)':
Ioi.cpp:39:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<from[x].size();i++) {
^
Ioi.cpp: In function 'int sssp(int)':
Ioi.cpp:33:12: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
return res;
^