Submission #1358753

#TimeUsernameProblemLanguageResultExecution timeMemory
1358753yogesh_saneSocial Engineering (EGOI22_socialengineering)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
using namespace std;

vector<bool> visited, challenger;
vector<vector<int>> paths, adj;
vector<int> friends;
vector<bool> challenged_by;
int last;


int dfs(int s){
    visited[s] = true;
    vector<int> unmatched;
    if(challenger[s])
        unmatched.push_back(s);
    for(auto u : adj[s]){
        if(!visited[u]){
            int uc = dfs(u);
            if(uc){
                paths[uc].push_back(s);
                unmatched.push_back(uc);
            }
        }
    }
    while(unmatched.size() >= 2){
        int a = unmatched.back();
        unmatched.pop_back();
        int b = unmatched.back();
        unmatched.pop_back();

        for(int f = paths[b].size()-2; f >= 0; f--)
            paths[a].push_back(paths[b][f]);
        if(paths[a].size() == 0 || paths[a].back() != b)
            paths[a].push_back(b);
        paths[b].clear();
        for(int f = paths[a].size()-2; f >= 0; f--)
            paths[b].push_back(paths[a][f]);
        if(paths[b].size() == 0 || paths[b].back() != a)
            paths[b].push_back(a);
    }
    return unmatched.size() > 0 ? unmatched[0] : 0;
}

void SocialEngineering(int n, int m, vector<pair<int, int>> edges){
    adj = vector<vector<int>>(n+1);
    challenger = vector<bool>(n+1);
    for(int i = 0; i < m; i++){
        int u = edges[i].first, v = edges[i].second;
        adj[u].push_back(v);
        adj[v].push_back(u);
        if(min(u,v) == 1)
            challenger[max(u,v)] = true;
    }
    visited = vector<bool>(n+1);
    paths = vector<vector<int>>(n+1);
    visited[1] = true;
    bool win = true;
    for(int i : adj[1]){
        if(!visited[i]){
            int uc = dfs(i);
            if(uc){
                win = false;
                break;
            }
        }
    }
    if(!win)
        return;
    int f = GetMove();
    while(f){
        for(auto c : paths[f])
            MakeMove(c);
        MakeMove(1);
        f = GetMove();
    }
    return;
}

Compilation message (stderr)

Main.cpp: In function 'void SocialEngineering(int, int, std::vector<std::pair<int, int> >)':
Main.cpp:70:13: error: 'GetMove' was not declared in this scope
   70 |     int f = GetMove();
      |             ^~~~~~~
Main.cpp:73:13: error: 'MakeMove' was not declared in this scope
   73 |             MakeMove(c);
      |             ^~~~~~~~
Main.cpp:74:9: error: 'MakeMove' was not declared in this scope
   74 |         MakeMove(1);
      |         ^~~~~~~~