Submission #549660

# Submission time Handle Problem Language Result Execution time Memory
549660 2022-04-16T08:37:03 Z AJ00 Library (JOI18_library) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
int n;
vector<int> res;
vector<vector<int>> adj(1001);
void dfs(int x, int p = 0){
    res.push_back(x);
    for (int ch: adj[x]){
        if (ch != p){
            dfs(ch,x);
        }
    }
}
void Solve(int N){
    n = N;
    vector<int> M(n);
    for (int i = 1; i <= n; i++){
        for (int j = i+1; j <= n; j++){
            memset(M, 0, sizeof M);
            M[i-1] = 1;
            M[j-1] = 1;
            int ans = Query(M);
            if (ans == 1){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }
    for (int i = 1; i <= n; i++){
        if (adj[i].size() == 1){
            dfs(i);
            break;
        }
    }
    Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:20:20: error: cannot convert 'std::vector<int>' to 'void*'
   20 |             memset(M, 0, sizeof M);
      |                    ^
      |                    |
      |                    std::vector<int>
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from library.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~