답안 #123322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123322 2019-07-01T07:20:09 Z baluteshih 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
0 / 100
33 ms 4544 KB
#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)
{
	//cout << u << " ";
	if(dis==k) return u==p;
	if(dis>k) return 0;
	for(int &i=cur[u];i<Gr[u].size();++i)
		if(!vis[Gr[u][i].S])
		{
			vis[Gr[u][i].S]=1,++dis;
			if(dfs(Gr[u][i].F)) return 1;
			++dis;//,cout << u << " ";
			if(dis==k) return u==p;
			if(dis>k) return 0;
		}
	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=0,vis.reset(),MEM(cur,0),/*cout << j << ": ",*/ans+=dfs(j);//,ET;
		answer(ans);
	}
}

Compilation message

garden.cpp: In function 'bool dfs(int)':
garden.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int &i=cur[u];i<Gr[u].size();++i)
                    ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4544 KB Output isn't correct
2 Halted 0 ms 0 KB -