이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[10005];
int g,ans,p;
map<string,int> h;
string s="";
void dfs(int x,int y,int k){
if(k==g and x==p){
//cout<<s<<endl;
h[s]=1;
ans++;
return;
}
else if(k>=g) return;
int l=s.size();
forr(i,0,adj[x].size()){
if(adj[x][i].nd==y and adj[x].size()==1){
s+=y;
dfs(y,x,k+1);
break;
}
else if(adj[x][i].nd!=y){
s+=(char)adj[x][i].nd;
dfs(adj[x][i].nd,x,k+1);
break;
}
}
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];
p=P;
forr(i,0,N){
dfs(i,i,0);
}
for(int i=0; i<Q; i++){
answer(h.size());
}
}
컴파일 시 표준 에러 (stderr) 메시지
garden.cpp: In function 'void dfs(int, int, int)':
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:28:7:
forr(i,0,adj[x].size()){
~~~~~~~~~~~~~~~~~
garden.cpp:28:2: note: in expansion of macro 'forr'
forr(i,0,adj[x].size()){
^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |