Submission #742698

#TimeUsernameProblemLanguageResultExecution timeMemory
742698vjudge1Friend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "friend.h"

using namespace std;

#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()

vector<int> g[1005];
bool visited[1005];
int p[1005], col[1005];

int dfs(int n) {
    for (auto x : g[n]) {
        if (visited[x]) continue;
        visited[x] = 1;
        if (p[x] == -1 || dfs(p[x])) {
            p[x] = n;
            return 1;
        }
    }
    return 0;
}

int findSample(int n, int confidence[], int host[], int protocol[]) {
    memset(p, -1, sizeof(p));
    for (int i = 0; i < n; i++) {
        if (protocol[i] == 0) {
            g[host[i]].push_back(i);
            g[i].push_back(host[i]);
            col[i] = col[host[i]] ^ 1;
        }
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        if (col[i] == 0) {
            memset(visited, 0, sizeof(vis));
            ans -= dfs(n);
        }
    }
    return ans;
}

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:38:39: error: 'vis' was not declared in this scope
   38 |             memset(visited, 0, sizeof(vis));
      |                                       ^~~