답안 #89103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89103 2018-12-10T10:07:05 Z beso123 특수한 그래프 (IZhO13_specialg) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int n,p[100001],q,d=1;
int used[100001];
int DFS(int v,int h){
    used[v]=d;
queue <int> q;
q.push(v);
int cnt=0;
while(!q.empty()){
v=q.front();
q.pop();
if(v==h){
    return cnt;
}
used[v]=d;
if(used[p[v]]!=d && p[v]!=0)
    q.push(p[v])<<endl;
cnt++;
}
        if(used[h]!=d)
            return -1;
}
int main(){
    cin>>n;
 
    for(int k=1;k<=n;k++)
        cin>>p[k];
    cin>>q;
    for(int k=1;k<=q;k++){
        int a;
        cin>>a;
        if(a==1){
            int b;
            cin>>b;
            p[b]=0;
        }
           if(a==2){
            int b,c;
            cin>>b>>c;
            d++;
cout<<DFS(b,c);
        }
    }

    return 0;
}

Compilation message

specialg.cpp: In function 'int DFS(int, int)':
specialg.cpp:18:17: error: invalid operands of types 'void' and '<unresolved overloaded function type>' to binary 'operator<<'
     q.push(p[v])<<endl;
     ~~~~~~~~~~~~^~~~~~
specialg.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^