답안 #167286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167286 2019-12-07T08:00:28 Z mhy908 Pipes (CEOI15_pipes) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
struct UNION_FIND{
    vector<int> par(100001);
    UNION_FIND(){for(int i=1; i<=100000; i++)par[i]=i;}
    int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);}
    void mergepar(int a, int b){par[findpar(a)]=findpar(b);}
    bool query(int a, int b){return findpar(a)==findpar(b);}
}uf1, uf2;
vector<int> link[100001];
int n, m, t;
vector<int> disc, lowlink, par;
void dfs(int u)
{
	disc[u]=lowlink[u]=++t;
	bool temp=false;
	for(int i=0; i<link[u].size(); i++){
		if(link[u][i]==par[u]&&!temp)temp=true;
		else{
			if(!disc[link[u][i]]){
				par[link[u][i]]=u;
				dfs(link[u][i]);
				if(lowlink[link[u][i]]>disc[u])printf("%d %d\n", u, link[u][i]);
				lowlink[u]=min(lowlink[u], lowlink[link[u][i]]);
			}
			else lowlink[u]=min(lowlink[u], disc[link[u][i]]);
		}
	}
}
int main()
{
    scanf("%d %d", &n, &m);
    for(int i=1; i<=m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        if(!uf1.query(u, v)){
            uf1.mergepar(u, v);
            link[u].pb(v);
            link[v].pb(u);
        }
        else if(!uf2.query(u, v)){
            uf2.mergepar(u, v);
            link[u].pb(v);
            link[v].pb(u);
        }
    }
    vector<int>().swap(uf1.par);
    vector<int>().swap(uf2.par);
    disc.resize(100001);
    lowlink.resize(100001);
    par.resize(100001);
    for(int i=1; i<=n; i++){
        if(!disc[i])dfs(i);
    }
}

Compilation message

pipes.cpp:11:21: error: expected identifier before numeric constant
     vector<int> par(100001);
                     ^~~~~~
pipes.cpp:11:21: error: expected ',' or '...' before numeric constant
pipes.cpp: In constructor 'UNION_FIND::UNION_FIND()':
pipes.cpp:12:51: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
     UNION_FIND(){for(int i=1; i<=100000; i++)par[i]=i;}
                                                   ^
pipes.cpp: In member function 'int UNION_FIND::findpar(int)':
pipes.cpp:13:45: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
     int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);}
                                             ^
pipes.cpp:13:58: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
     int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);}
                                                          ^
pipes.cpp:13:75: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
     int findpar(int num){return num==par[num]?num:par[num]=findpar(par[num]);}
                                                                           ^
pipes.cpp: In member function 'void UNION_FIND::mergepar(int, int)':
pipes.cpp:14:47: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
     void mergepar(int a, int b){par[findpar(a)]=findpar(b);}
                                               ^
pipes.cpp: In function 'void dfs(int)':
pipes.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<link[u].size(); i++){
               ~^~~~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:54:31: error: invalid use of non-static member function 'std::vector<int> UNION_FIND::par(int)'
     vector<int>().swap(uf1.par);
                               ^
pipes.cpp:11:17: note: declared here
     vector<int> par(100001);
                 ^~~
pipes.cpp:55:31: error: invalid use of non-static member function 'std::vector<int> UNION_FIND::par(int)'
     vector<int>().swap(uf2.par);
                               ^
pipes.cpp:11:17: note: declared here
     vector<int> par(100001);
                 ^~~
pipes.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~