Submission #874886

# Submission time Handle Problem Language Result Execution time Memory
874886 2023-11-18T03:32:19 Z eu_caue Library (JOI18_library) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;

int l[maxn], r[maxn];
int pai1[maxn], pai2[maxn];
vector<int> heads1, heads2;

int find1(int x){
    return pai1[x] = pai1[x] == x ? x : find1(pai1[x]);
}

int find2(int x){
    return pai2[x] = pai2[x] == x ? x : find2(pai2[x]);
}

int Q1(int tl, int tr, int i, int n){
    if(tl == tr) return tl;
    int mid = (tl+tr)>>1;
    vector<int> q(n,0);
    for(int j = tl; j <= mid; j++) q[find1(heads1[j])-1] = 1;
    q[i-1] = 1;
    int f = Query(q);
    if(f == heads1.size()) return Q1(tl, mid, i, n);
    return Q1(mid+1, tr, i, n);
}

int Q2(int tl, int tr, int i, int n){
    if(tl == tr) return tl;
    int mid = (tl+tr)>>1;
    vector<int> q(n,0);
    for(int j = tl; j <= mid; j++) q[find2(heads2[j])-1] = 1;
    q[i-1] = 1;
    int f = Query(q);
    if(f == heads2.size()) return Q2(tl, mid, i, n);
    return Q2(mid+1, tr, i, n);
}

void Solve(int n){
    vector<int> ans(n,0);
    for(int i = 1; i <= n; i++) pai1[i] = pai2[i] = i;
    memset(l, -1, sizeof(l)), memset(r, -1, sizeof(r));
    for(int i = 1; i <= n; i++){
        vector<int> q1(n,0);
        for(auto j : heads1) q1[find2(j)-1] = 1;
        q1[i-1] = 1;
        int f = Query(q1);
        if(f == heads1.size()+1){
            heads1.push_back(i);
        }
        else{
            int v = Q1(0, heads1.size(), i, n);
            l[heads1[v]] = pai1[heads1[v]] = i;
            heads1[v] = i;
        }
        // vector<int> q2(n,0);
        // for(auto j : heads2) q2[find1(j)-1] = 1;
        // q2[i-1] = 1;
        // f = Query(q2);
        // if(f == heads2.size()+1){
        //     heads2.push_back(i);
        // }
        // else{
        //     int v = Q1(0, heads1.size(), i, n);
        //     l[heads2[v]] = pai1[heads2[v]] = i;
        //     heads2[v] = i;
        // }
    }
    int s;
    for(int i = 1; i <= n; i++) if(l[i] == -1) s = i;
    vector<int> ans(n);
    ans[0] = s;
    for(int i = 1; i < n; i++) ans[i] = l[ans[i-1]];
    Answer(ans);
}

Compilation message

library.cpp: In function 'int Q1(int, int, int, int)':
library.cpp:23:13: error: 'Query' was not declared in this scope
   23 |     int f = Query(q);
      |             ^~~~~
library.cpp:24:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     if(f == heads1.size()) return Q1(tl, mid, i, n);
      |        ~~^~~~~~~~~~~~~~~~
library.cpp: In function 'int Q2(int, int, int, int)':
library.cpp:34:13: error: 'Query' was not declared in this scope
   34 |     int f = Query(q);
      |             ^~~~~
library.cpp:35:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(f == heads2.size()) return Q2(tl, mid, i, n);
      |        ~~^~~~~~~~~~~~~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:47:17: error: 'Query' was not declared in this scope
   47 |         int f = Query(q1);
      |                 ^~~~~
library.cpp:48:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(f == heads1.size()+1){
      |            ~~^~~~~~~~~~~~~~~~~~
library.cpp:71:17: error: redeclaration of 'std::vector<int> ans'
   71 |     vector<int> ans(n);
      |                 ^~~
library.cpp:40:17: note: 'std::vector<int> ans' previously declared here
   40 |     vector<int> ans(n,0);
      |                 ^~~
library.cpp:74:5: error: 'Answer' was not declared in this scope
   74 |     Answer(ans);
      |     ^~~~~~