Submission #116965

#TimeUsernameProblemLanguageResultExecution timeMemory
116965SortingWerewolf (IOI18_werewolf)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 2e5 + 7;
const int LOGN = 20;
 
vector<int> adj[MAXN], ans;
vector<int> U[MAXN], V[MAXN];

struct dsu{
    int par[MAXN], cnt[MAXN];
    
    dsu(){}
    
    dsu(int N){
        for(int i = 0; i < N; i++){
            par[i] = i;
            cnt[i] = 1;
        }
    }
    
    void find_par(int u){
        if(u == par[u]){
            return;
        }
        
        find_par(u);
        par[u] = par[par[u]];
    }
    
    bool unite(int u, int v){
        find_par(u);
        find_par(v);
        
        if(par[u] == par[v]){
            return false;
        }
        
        if(cnt[par[u]] < cnt[par[v]]){
            swap(u, v);
        }
        
        cnt[par[u]] += cnt[par[v]];
        par[par[v]] = par[u];
        
        return true;
    }
};

dsu du, dv;

vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){
	for(int i = 0; i < X.size(); i++){
		adj[X[i]].push_back(Y[i]);
		adj[Y[i]].push_back(X[i]);
	}
	
	n = N;
	du = dsu(N);
	dv = dsu(N);
	
    for(int i = 0; i < N; i++){
        for(int to: adj[i]){
            if(du.unite(i, to)){
                U[i].push_back(to);
                U[to].push_back(i);
            }
        }
    }
    
    for(int i = N - 1; i >= 0; i--){
        for(int to: adj[i]){
            if(dv.unite(i, to)){
                V[i].push_back(to);
                V[to].push_back(i);
            }
        }
    }
}
 
/*vector<int> xv, yv, sv, ev, lv, rv;
 
int main(){
	int n, m;
 
	cin >> n >> m;
 
	for(int i = 0; i < m; i++){
		int x, y;
 
		cin >> x >> y;
 
		xv.push_back(x);
		yv.push_back(y);
	}
 
	int q;
 
	cin >> q;
 
	for(int i = 0; i < q; i++){
		int sx, ex, lx, rx;
 
		cin >> sx >> ex >> lx >> rx;
 
		sv.push_back(sx);
		ev.push_back(ex);
		lv.push_back(lx);
		rv.push_back(rx);
	}
 
	vector<int> res = check_validity(n, xv, yv, sv, ev, lv, rv);
 
	for(int t: res){
		cout << t << " ";
	}
	cout << endl;
 
	return 0;
}*/
/*
2 1
0 1
2
0 1 1 1
1 0 1 2
*/

Compilation message (stderr)

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < X.size(); i++){
                 ~~^~~~~~~~~~
werewolf.cpp:59:2: error: 'n' was not declared in this scope
  n = N;
  ^
werewolf.cpp:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^