Submission #466758

# Submission time Handle Problem Language Result Execution time Memory
466758 2021-08-20T15:53:56 Z MohamedFaresNebili Portals (BOI14_portals) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gift.h"
using namespace std;

vector<int>parent;
void init(int n) { parent.resize(n); for(int l=0;l<n;l++) parent[l]=l; }
int findset(int n) { return (parent[n]==n)?n:(parent[n]=findset(parent[n])); }
bool sameSet(int a, int b) { return findset(a)==findset(b); }
void unionSet(int a, int b) {
    if(sameSet(a, b)) return;
    a=findset(a); b=findset(b);
    if(a < b)
    parent[a]=b;
    else parent[b] = a;
}

int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
    init(n+1);
    for(int i = 0; i < r; i++){
        if(x[i] == 2) continue;
        int j = findset(a[i]);
        
        while(j<b[i]&&findset(j) != findset(b[i])){
            unionSet(j,b[i]);
            j++;
        }
    }

    for(int i=0;i<r;i++){
        if(x[i]==1){
            continue;
        }
        if(findset(a[i])==findset(b[i])){
            return 0;
        }
    }
    string s ="R";
    
    for(int i=1;i<n;i++)
    {
        if(findset(i) != findset(i-1)) {
          if(s.back() == 'R')s += "B";
       	 else s+= "R";
        }
        else s+= s.back();
    }
    craft(s);
    return 1;
}

Compilation message

portals.cpp:2:10: fatal error: gift.h: No such file or directory
    2 | #include "gift.h"
      |          ^~~~~~~~
compilation terminated.