이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
bitset<150005> vis;
vector<pii> Gr[150005];
int k,p,cur[150005],dis;
bool dfs(int u,int f)
{
//cout << u << " ";
++dis;
if(dis==k) return u==p;
if(dis>k) return 0;
if(Gr[u][0].S!=f)
if(dfs(Gr[u][0].F,Gr[u][0].S)==1) return 1;
else return 0;
if(Gr[u].size()>1)
if(dfs(Gr[u][1].F,Gr[u][1].S)==1) return 1;
else return 0;
if(dfs(Gr[u][0].F,Gr[u][0].S)==1) return 1;
return 0;
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
p=P;
for(int i=0;i<M;++i)
Gr[R[i][0]].pb(MP(R[i][1],i)),Gr[R[i][1]].pb(MP(R[i][0],i));
for(int i=0;i<Q;++i)
{
int ans=0;
k=G[i];
for(int j=0;j<N;++j)
dis=-1,/*,cout << j << ": ",*/ans+=dfs(j,-1);//,ET;
answer(ans);
}
}
컴파일 시 표준 에러 (stderr) 메시지
garden.cpp: In function 'bool dfs(int, int)':
garden.cpp:28:4: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
if(Gr[u][0].S!=f)
^
garden.cpp:31:4: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
if(Gr[u].size()>1)
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |