#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;
void dfs(int x,int y,string s){
if(g<s.size()) return;
if(g==s.size()){
h[s]=1;
return;
}
forr(i,0,adj[x].size()){
if(adj[x].size()==1){
s+=(char)y;
dfs(y,x,s);
}
else{
if(y==adj[x][0].nd){
s+=(char)adj[x][1].nd;
dfs(adj[x][1].nd,x,s);
}
else{
s+=(char)adj[x][0].nd;
dfs(adj[x][0].nd,x,s);
}
}
}
}
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;
string str="";
str+=c;
dfs(P,-1,str);
for(int i=0; i<Q; i++){
answer(h.size());
}
}
Compilation message
garden.cpp: In function 'void dfs(int, int, std::__cxx11::string)':
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:25:7:
forr(i,0,adj[x].size()){
~~~~~~~~~~~~~~~~~
garden.cpp:25:2: note: in expansion of macro 'forr'
forr(i,0,adj[x].size()){
^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1465 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 |
1465 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 |
1465 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |