Submission #940466

# Submission time Handle Problem Language Result Execution time Memory
940466 2024-03-07T09:42:54 Z groshi Library (JOI18_library) C++17
100 / 100
210 ms 704 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
int zaliczony[2000];
/*int Query(vector<int> pyt)
{
    for(int i=0;i<pyt.size();i++)
        cout<<pyt[i]<<" ";
    int wynik;
    cin>>wynik;
    return wynik;
}
void Answer(vector<int> wynik)
{
    cout<<"wynik - > ";
    for(int i=0;i<wynik.size();i++)
        cout<<wynik[i]<<" ";
}*/
void Solve(int n)
{
    if(n==1)
    {
        Answer({1});
        return;
    }
    vector<int> pytaj;
    for(int i=1;i<=n;i++)
        pytaj.push_back(1);
    int ost;
    vector<int> wynik;
    for(int i=0;i<n;i++)
    {
        pytaj[i]=0;
        if(Query(pytaj)==1)
        {
            ost=i;
            wynik.push_back(i+1);
            zaliczony[i]=1;
            break;
        }
        pytaj[i]=1;
    }
    for(int i=1;i<n;i++)
    {
        vector<int> niema;
        for(int j=0;j<n;j++)
            if(zaliczony[j]==0)
                niema.push_back(j);
        int pocz=0,kon=niema.size(),sre,ostd=0;
        while(pocz<kon)
        {
            //cout<<i<<": "<<pocz<<" "<<kon<<"\n";
            sre=(pocz+kon)/2;
            vector<int> pytaj;
            for(int j=0;j<n;j++)
                pytaj.push_back(0);
            for(int j=0;j<=sre;j++)
                pytaj[niema[j]]=1;
            int essa=Query(pytaj);
            pytaj[ost]=1;
            if(Query(pytaj)==essa)
            {
                ostd=sre;
                kon=sre;
            }
            else pocz=sre+1;
        }
        wynik.push_back(niema[ostd]+1);
        zaliczony[niema[ostd]]=1;
        ost=niema[ostd];
    }
    Answer(wynik);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:60:22: warning: 'ost' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |             pytaj[ost]=1;
      |                      ^
# Verdict Execution time Memory Grader output
1 Correct 21 ms 344 KB # of queries: 2411
2 Correct 20 ms 344 KB # of queries: 2455
3 Correct 22 ms 344 KB # of queries: 2664
4 Correct 24 ms 344 KB # of queries: 2613
5 Correct 24 ms 344 KB # of queries: 2534
6 Correct 20 ms 344 KB # of queries: 2567
7 Correct 26 ms 344 KB # of queries: 2580
8 Correct 23 ms 344 KB # of queries: 2416
9 Correct 23 ms 344 KB # of queries: 2552
10 Correct 9 ms 344 KB # of queries: 1494
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 3
13 Correct 0 ms 344 KB # of queries: 8
14 Correct 0 ms 344 KB # of queries: 11
15 Correct 1 ms 344 KB # of queries: 85
16 Correct 1 ms 344 KB # of queries: 195
# Verdict Execution time Memory Grader output
1 Correct 21 ms 344 KB # of queries: 2411
2 Correct 20 ms 344 KB # of queries: 2455
3 Correct 22 ms 344 KB # of queries: 2664
4 Correct 24 ms 344 KB # of queries: 2613
5 Correct 24 ms 344 KB # of queries: 2534
6 Correct 20 ms 344 KB # of queries: 2567
7 Correct 26 ms 344 KB # of queries: 2580
8 Correct 23 ms 344 KB # of queries: 2416
9 Correct 23 ms 344 KB # of queries: 2552
10 Correct 9 ms 344 KB # of queries: 1494
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 3
13 Correct 0 ms 344 KB # of queries: 8
14 Correct 0 ms 344 KB # of queries: 11
15 Correct 1 ms 344 KB # of queries: 85
16 Correct 1 ms 344 KB # of queries: 195
17 Correct 192 ms 452 KB # of queries: 18050
18 Correct 187 ms 600 KB # of queries: 17249
19 Correct 199 ms 704 KB # of queries: 17493
20 Correct 183 ms 448 KB # of queries: 16333
21 Correct 164 ms 440 KB # of queries: 15390
22 Correct 198 ms 704 KB # of queries: 17681
23 Correct 183 ms 448 KB # of queries: 17244
24 Correct 78 ms 452 KB # of queries: 7909
25 Correct 188 ms 460 KB # of queries: 17150
26 Correct 173 ms 700 KB # of queries: 16033
27 Correct 79 ms 692 KB # of queries: 8020
28 Correct 210 ms 444 KB # of queries: 17955
29 Correct 174 ms 456 KB # of queries: 17935
30 Correct 187 ms 448 KB # of queries: 17955