Submission #154079

# Submission time Handle Problem Language Result Execution time Memory
154079 2019-09-18T10:09:29 Z stefantaga Bulb Game (FXCUP4_bulb) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "bulb.h"
using namespace std;
struct bec
{
    int st,dr;
}val[300005];
bool notbec (int nr)
{
    if (nr==-1||nr==-2)
    {
        return 0;
    }
    return 1;
}
void dfs (int x,vector <int> l,vector <int> r)
{
    if (notbec(l[x]))
    {
        dfs(l[x],l,r);
        val[x].st=val[l[x]].st;
    }
    else
    {
        val[x].st=l[x];
    }
    if (notbec(r[x]))
    {
        dfs(r[x],l,r);
        val[x].dr=val[r[x]].st;
    }
    else
    {
        val[x].dr=r[x];
    }
}
int FindWinner(int t,vector<int> l,vector<int> r)
{
	int n= l.size(),poz,poz1;
	poz=0;
	while (poz!=-1&&poz!=-2)
    {
        poz=l[poz];
    }
    if (poz==-2)
    {
    return 0;
    }
    else
    {
        dfs(0,l,r);
        poz=0;
        q=0;
        ok=0;
        ok1=0;
        pozitie=0;
        while (notbec(poz))
        {
            poz1=r[poz];
            
            while (notbec(poz1))
            {
                if (val[r[poz1]].st==-1)
                {
                    ok=1;
                    break;
                }
                poz1=l[poz1];
            }
            if (val[r[poz]].st==-2)
            {
                if (pozitie==0)
                {
                    pozitie=poz;
                }
                ok1=1;
            }
            poz=l[poz];
        }
        if (ok1==0)
        {
            if (ok==1)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        else
        if (ok1==1)
        {
            poz=l[pozitie];
            while (notbec(poz)==1)
            {
                if (val[r[poz]].st==-2)
                {
                    return 0;
                }
                poz=l[poz];
            }
            poz=r[pozitie];
            while (notbec(poz)==1)
            {
                if (val[r[poz]].st==-1)
                {
                    return 1;
                }
                poz=l[poz];
            }
            return 1;
        }
    }
}

Compilation message

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:53:9: error: 'q' was not declared in this scope
         q=0;
         ^
bulb.cpp:54:9: error: 'ok' was not declared in this scope
         ok=0;
         ^~
bulb.cpp:55:9: error: 'ok1' was not declared in this scope
         ok1=0;
         ^~~
bulb.cpp:55:9: note: suggested alternative: 'poz1'
         ok1=0;
         ^~~
         poz1
bulb.cpp:56:9: error: 'pozitie' was not declared in this scope
         pozitie=0;
         ^~~~~~~
bulb.cpp:39:6: warning: unused variable 'n' [-Wunused-variable]
  int n= l.size(),poz,poz1;
      ^
bulb.cpp:115:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^