Submission #807518

# Submission time Handle Problem Language Result Execution time Memory
807518 2023-08-04T18:48:17 Z Ozy Digital Circuit (IOI22_circuit) C++17
Compilation error
0 ms 0 KB
#include "islands.h"
#include <bits/stdc++.h>
#include <variant>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>

#define MAX 1000
//para el vector de hijos
#define des first
#define id second

vector<int> camino;
lli a,b,c,d,n;
lli vis[MAX+2];
stack<pll> pila;
vector<pll> hijos[MAX+2];

bool dfs(lli pos,lli rama){
  if(rama != -1) {
    pila.push({pos,rama});
    camino.push_back(rama);
  }

  if (vis[pos] == 1) { //estoy en un ciclo

    vector<lli> orden;
    orden.push_back(rama);
    pila.pop();

    while (!pila.empty() && pila.top().des != pos) {
      orden.push_back(pila.top().id);
      vis[pila.top().des] = 2;
      pila.pop();
    }
    
    reverse(orden.begin(), orden.end());
    for(auto act : orden) camino.push_back(act^1);

    reverse(orden.begin(), orden.end());
    for(auto act : orden) camino.push_back(act);
    for(auto act : orden) camino.push_back(act^1);

    return true;
  }

  vis[pos] = 1;
  bool puedo = false;
  for (auto h : hijos[pos]) {
    if(dfs(h.des,h.id)) {
      puedo = true;
      break;
    }
  }

  if (!puedo) {
    return false;
    if (rama != -1) pila.pop();
  }
  if (vis[pos] == 1 && rama >= 0) camino.push_back(rama);
  return true;
}

//solucion para la subtask #4
std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) {
  n = N;

  rep(i,0,M-1) {
    if(i&1) continue;
    hijos[U[i]].push_back({V[i],i});
  }

  if (dfs(0,-1)) return camino;
  else return false;
}
//que no se te olvide sacar de la pila

Compilation message

circuit.cpp:1:10: fatal error: islands.h: No such file or directory
    1 | #include "islands.h"
      |          ^~~~~~~~~~~
compilation terminated.