Submission #982786

# Submission time Handle Problem Language Result Execution time Memory
982786 2024-05-14T17:59:31 Z alo_54 Game (APIO22_game) C++17
0 / 100
0 ms 344 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

struct Nodo
{
  vector <int> ady;
  bool special = false;

};

vector <Nodo> g;
vector <bool> vis;
bool acPos = 0;

int dfs(int node)
{
  //cout<<"call "<<node<<endl;

  vis[node] = true;

  int resp = 0;
  
  for (auto i : g[node].ady)
  {
    //cout<<"check "<<i<<endl;
    if (!vis[i])
    {
      resp = dfs(i);
    }else
    {
      if (g[i].special)
      {
        resp = 1;
      }
      
      
    }
  }

  return resp;


}

void init(int n, int k) 
{
  vis.resize(n);
  g.resize(n);
  
  for (int i = 0; i < k; i++)
  {
    g[i].special = true;
    
  }
  
}

int add_teleporter(int u, int v) 
{
  fill(vis.begin(), vis.end(), false);
  g[u].ady.push_back(v);

  int resp = acPos;

  for (auto i : g)
  {
    if (i.special)
    {
      resp = dfs(u);

      if (resp == 1)
      {
        acPos = true;
        break;
      }
      
    }
    
  }

  if (acPos)
  {
    resp = true;
  }
  
  
  return resp;
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -