Submission #127664

#TimeUsernameProblemLanguageResultExecution timeMemory
127664MasterdanSimurgh (IOI17_simurgh)C++14
Compilation error
0 ms0 KiB

	#include "simurgh.h"
#include <bits/stdc++.h>
#define MIN -1
#define MAX 1000000000
#define pb push_back
#define mp   make _pair
#define all(a)  a.begin (), a.end ()
using namespace std;
typedef long long int ll;
typedef vector <int> vi;
int p[500];
int m,n;
bool aux[500];
vector<pair<int,int>> g[500];
vector<int> u,v;
 
int findset(int x){

	return x == p[x] ? x : p[x] = findset(p[x]);
}
 
bool initset(vector<int> ans){
	for(int i=0;i<n;i++)
		p[i] = i;
	for(int i=0;i<ans.size();i++){
		int id = ans[i];
		int a = u[id];
		int b = v[id];
		if(findset(a) == findset(b))
			continue;
		p[findset(b)] = findset(a);
	}
	for(int i=0;i<n;i++){
		if(findset(i) != findset(0))
		  return 0;}
	return 1;
}
 
vector<int> find_roads(int N, vector<int> U, vector<int> V) {
	vector<int> ans;
	u = U;
	v = V;
	n = N;
	m = u.size();
 
	for(int i=0;i<n;i++)
		p[i] = i;
 
	int lst;
	for(int i=0;i<m;i++){
		int a = u[i];
		int b = v[i];
		g[a].push_back({b,i});
		g[b].push_back({a,i});
		if(findset(a) == findset(b))
			continue;
		aux[i] = 1;
		ans.push_back(i);
		p[findset(b)] = findset(a);
	}
	lst = count_common_roads(ans);
	for(int i=0;i<ans.size();i++){
		int id = ans[i];
		int a = u[id];
		int b = v[id];
		for(int j=0;j<m;j++){
			if(aux[j])
				continue;
			ans[i] = j;
			if(initset(ans) == 1){
				int r = count_common_roads(ans);
				if(r < lst){
					ans[i] = id;
					break;
				}
				if(r > lst){
					lst = r;
					aux[j] = 1;
					aux[id] = 0;
					break;
				}
			}
			ans[i] = id;
		}
	}
	return ans;
}				

Compilation message (stderr)

simurgh.cpp:20:10: error: stray '\302' in program
  return x == p[x] ? x : p[x] = findset(p[x]);
          ^
simurgh.cpp:20:11: error: stray '\240' in program
  return x == p[x] ? x : p[x] = findset(p[x]);
           ^
simurgh.cpp: In function 'bool initset(std::vector<int>)':
simurgh.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans.size();i++){
              ~^~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:63:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans.size();i++){
              ~^~~~~~~~~~~
simurgh.cpp:65:7: warning: unused variable 'a' [-Wunused-variable]
   int a = u[id];
       ^
simurgh.cpp:66:7: warning: unused variable 'b' [-Wunused-variable]
   int b = v[id];
       ^