답안 #28841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28841 2017-07-17T10:07:49 Z dereotu 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
0 / 100
1034 ms 262148 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;

vector <pair<int,int> > adj[1005];
map<string,int> h;
int g;
string s;
void dfs(int x,int y){
	if(g<s.size()) return;
	if(g==s.size()){
		h[s]=1;
		return;
	}
	int l=s.size();
	forr(i,0,adj[x].size()){
		if(adj[x].size()==1){
			s+=(char)y;
			dfs(y,x);
		}
		else{
			if(y==adj[x][0].nd){
				s+=(char)adj[x][1].nd;
				dfs(adj[x][1].nd,x);
			}
			else{
				s+=(char)adj[x][0].nd;
				dfs(adj[x][0].nd,x);
			}
		}
	}
	s.resize(l);
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
	forr(i,0,N){
		adj[R[i][0]].pb(mp(i,R[i][1]));
		adj[R[i][1]].pb(mp(i,R[i][0]));
	}
	forr(i,0,N){
		sort(adj[R[i][0]].begin(),adj[R[i][0]].end());
		sort(adj[R[i][1]].begin(),adj[R[i][1]].end());
	}
	g=G[0];
	char c=(char)P;
	s+=c;
	dfs(P,-1);
	for(int i=0; i<Q; i++){
   		answer(h.size());
	}
}


Compilation message

garden.cpp: In function 'void dfs(int, int)':
garden.cpp:20:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(g<s.size()) return;
     ~^~~~~~~~~
garden.cpp:21:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(g==s.size()){
     ~^~~~~~~~~~
garden.cpp:9:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define forr(i,A,B) for(int i=A;i<B;++i)
garden.cpp:26:7:
  forr(i,0,adj[x].size()){
       ~~~~~~~~~~~~~~~~~           
garden.cpp:26:2: note: in expansion of macro 'forr'
  forr(i,0,adj[x].size()){
  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1034 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1034 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1034 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -