제출 #339428

#제출 시각아이디문제언어결과실행 시간메모리
339428beksultan04특수한 그래프 (IZhO13_specialg)C++14
0 / 100
59 ms65540 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-15 const int N = 1e5+12,INF=1e9+7; vector <int> g[N]; int ans; bool vis[N]; void dfs(int x,int y,int cnt=0){ vis[x]=1; if (x == y){ ans = cnt; ret ; } if (ans > 0 )ret ; for (int i=0;i<g[x].size();++i){ dfs(g[x][i],y,cnt+1); } vis[x]=0; } main(){ int n,i,j,m; cin>>n; for (i=1;i<=n;++i){ int x; cin>>x; if (x)g[i].pb(x); } cin>>m; while (m--){ int t; cin>>t; if (t==1){ int x; cin>>x; g[x].pop_back(); } else { int x,y; cin>>x>>y; ans=-1; dfs(x,y); cout <<ans<<'\n'; } } }

컴파일 시 표준 에러 (stderr) 메시지

specialg.cpp: In function 'void dfs(int, int, int)':
specialg.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i=0;i<g[x].size();++i){
      |                  ~^~~~~~~~~~~~
specialg.cpp: At global scope:
specialg.cpp:39:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main(){
      |      ^
specialg.cpp: In function 'int main()':
specialg.cpp:40:13: warning: unused variable 'j' [-Wunused-variable]
   40 |     int n,i,j,m;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...