Submission #1093865

# Submission time Handle Problem Language Result Execution time Memory
1093865 2024-09-27T21:00:20 Z DobromirAngelov Library (JOI18_library) C++14
0 / 100
37 ms 444 KB
#include "library.h"
#include<bits/stdc++.h>

using namespace std;

const int MAXN=1005;

int n;
vector<int> m;
bool used[MAXN];

int queryNot(int ind)
{
    for(int i=0;i<n;i++)
    {
        m[i]=1;
        if(i==ind-1) m[i]=0;
    }
    return Query(m);
}

int query(vector<int> v)
{
    for(int i=0;i<n;i++) m[i]=0;
    for(auto x: v) m[x-1]=1;
    return Query(m);
}

void Solve(int N)
{
    n=N;
    m.resize(n);

    int st=0;
    for(int i=1;i<=n;i++)
    {
        if(queryNot(i)==1)
        {
            st=i;
            break;
        }
    }

    vector<int> res;
    res.push_back(st);
    used[st]=1;
    vector<int> pot;
    pot.reserve(n);
    for(int i=2;i<=n;i++)
    {
        pot.clear();
        for(int j=1;j<=n;j++)
        {
            if(!used[j]) pot.push_back(j);
        }

        int nxt=0;
        for(int j=0;(1<<j)<=pot.size();j++)
        {
            vector<int> cur;
            for(int k=0;k<pot.size();k++)
            {
                if(k&(1<<j)) cur.push_back(pot[k]);
            }
            if(cur.size()<=0) continue;
            int cnt1=query(cur);
            cur.push_back(res.back());
            int cnt2=query(cur);
            if(cnt1==cnt2) nxt|=(1<<j);
        }
        res.push_back(pot[nxt]);
        used[res.back()]=1;
    }

    Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:58:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(int j=0;(1<<j)<=pot.size();j++)
      |                     ~~~~~~^~~~~~~~~~~~
library.cpp:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             for(int k=0;k<pot.size();k++)
      |                         ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 344 KB # of queries: 2563
2 Correct 25 ms 344 KB # of queries: 2599
3 Correct 22 ms 348 KB # of queries: 2816
4 Correct 27 ms 344 KB # of queries: 2765
5 Correct 36 ms 416 KB # of queries: 2680
6 Correct 37 ms 424 KB # of queries: 2727
7 Correct 18 ms 348 KB # of queries: 2736
8 Correct 23 ms 348 KB # of queries: 2590
9 Correct 31 ms 444 KB # of queries: 2710
10 Correct 14 ms 348 KB # of queries: 1572
11 Runtime error 1 ms 344 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 344 KB # of queries: 2563
2 Correct 25 ms 344 KB # of queries: 2599
3 Correct 22 ms 348 KB # of queries: 2816
4 Correct 27 ms 344 KB # of queries: 2765
5 Correct 36 ms 416 KB # of queries: 2680
6 Correct 37 ms 424 KB # of queries: 2727
7 Correct 18 ms 348 KB # of queries: 2736
8 Correct 23 ms 348 KB # of queries: 2590
9 Correct 31 ms 444 KB # of queries: 2710
10 Correct 14 ms 348 KB # of queries: 1572
11 Runtime error 1 ms 344 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -