답안 #940401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
940401 2024-03-07T08:54:46 Z groshi 도서관 (JOI18_library) C++17
0 / 100
27 ms 436 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)
{
    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:55:22: warning: 'ost' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |             pytaj[ost]=1;
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 344 KB # of queries: 2411
2 Correct 20 ms 344 KB # of queries: 2455
3 Correct 26 ms 344 KB # of queries: 2664
4 Correct 21 ms 344 KB # of queries: 2613
5 Correct 21 ms 344 KB # of queries: 2534
6 Correct 27 ms 344 KB # of queries: 2567
7 Correct 21 ms 344 KB # of queries: 2580
8 Correct 20 ms 344 KB # of queries: 2416
9 Correct 20 ms 340 KB # of queries: 2552
10 Correct 10 ms 344 KB # of queries: 1494
11 Runtime error 0 ms 436 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 344 KB # of queries: 2411
2 Correct 20 ms 344 KB # of queries: 2455
3 Correct 26 ms 344 KB # of queries: 2664
4 Correct 21 ms 344 KB # of queries: 2613
5 Correct 21 ms 344 KB # of queries: 2534
6 Correct 27 ms 344 KB # of queries: 2567
7 Correct 21 ms 344 KB # of queries: 2580
8 Correct 20 ms 344 KB # of queries: 2416
9 Correct 20 ms 340 KB # of queries: 2552
10 Correct 10 ms 344 KB # of queries: 1494
11 Runtime error 0 ms 436 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -