제출 #123336

#제출 시각아이디문제언어결과실행 시간메모리
123336baluteshihTropical Garden (IOI11_garden)C++14
49 / 100
5018 ms4856 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...