Submission #47841

# Submission time Handle Problem Language Result Execution time Memory
47841 2018-05-08T06:24:46 Z mirbek01 Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N){
      vector <int> res(N), M(N), used(N), a(N), b(N);
      memset(used, 0, sizeof(used));
      int cur = 0, p1 = 0;
      a[0] = 0;
      b[0] = 0;
      used[0] = 1;

      while(1){
            int cn = 0;
            for(int i = 0; i < N; i ++){
                  if(used[i]) continue;
                  M[cur] = 1;
                  M[i] = 1;
                  int re = Query(M);
                  M[cur] = 0;
                  M[i] = 0;
                  if(re == 1){
                        used[i] = 1;
                        a[++ p1] = i;
                        cur = i;
                        break;
                  }
            }
            if(!cn) break;
      }
      cur = 0;
      int p2 = 0;
      while(1){
            int cn = 0;
            for(int i = 0; i < N; i ++){
                  if(used[i]) continue;
                  M[cur] = 1;
                  M[i] = 1;
                  int re = Query(M);
                  M[cur] = 0;
                  M[i] = 0;
                  if(re == 1){
                        used[i] = 1;
                        b[++ p2] = i;
                        cur = i;
                        break;
                  }
            }
            if(!cn) break;
      }
      int ps = 0;
      for(int i = p2; i > 0; i --){
            res[ps ++] = b[i] + 1;
      }
      for(int i = 0; i <= p1; i ++){
            res[ps ++] = a[i] + 1;
      }

	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:8:7: error: 'memset' was not declared in this scope
       memset(used, 0, sizeof(used));
       ^~~~~~