Submission #582034

# Submission time Handle Problem Language Result Execution time Memory
582034 2022-06-23T09:49:35 Z Abdulmohsen1284 Library (JOI18_library) C++14
100 / 100
523 ms 328 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include"bits/stdc++.h"
using namespace std;
long long s=0;
vector <int> em;
vector <int> rec(long long cur,vector <int> &grp)
{
    
        long long sum=0;
        for(int i=0;i<(int)grp.size();i++)
        {
            if(grp[i]==1)
                sum++;
        }
        if(s==0)
            Answer(em);
        vector <int> on=em,tw=em;
        long long took=0;
        for(int i=0;took<sum/2;i++)
        {
            if(i>=(int)grp.size())
                break;
            if(grp[i]==1)
            {
                took++;
                on[i]=grp[i];
            }
        }
        for(int i=0;i<(int)grp.size();i++)
        {
            if((grp[i]^on[i])==1)
                tw[i]=1;
        }
        //grp.clear();
        long long ch=Query(on);
        on[cur-1]=1;
        if(ch==Query(on))
        {
            on[cur-1]=0;
            return on;
        }
        else
        {
            return tw;
        }
}

void Solve(int N)
{
    if(N==1)
    {
        em.push_back(1);
        Answer(em);
        return;
    }
    for(int i=1;i<=N;i++)
        em.push_back(0);
    for(int i=1;i<=N;i++)
    {
        vector <int> ask=em;
        for(int j=1;j<=N;j++)
        {
            if(i==j)
                continue;
            ask[j-1]=1;
        }
        long long ans=Query(ask);
        if(ans==1)
        {
            s=i;
            break;
        }
    }
    vector <int> ret,lef=em;
    ret.push_back(s);
    for(int i=1;i<=N;i++)
    {
        if(s==i)
            continue;
        lef[i-1]=1;
    }
    for(int i=1;i<N;i++)
    {
        vector <int> gr=lef;
        while(0==0)
        {
            long long sum=0;
            for(int j=0;j<gr.size();j++)
            {
                sum+=gr[j];
            }
            if(sum==1)
            {
                for(int j=0;j<gr.size();j++)
                {
                    if(gr[j]==1)
                    {
                        s=j+1;
                    }
                }
                break;
            }
            else
            gr=rec(s,gr);
        }
        ret.push_back(s);
        lef[s-1]=0;
    }
    
    Answer(ret);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:90:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for(int j=0;j<gr.size();j++)
      |                         ~^~~~~~~~~~
library.cpp:96:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |                 for(int j=0;j<gr.size();j++)
      |                             ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 33 ms 284 KB # of queries: 2375
2 Correct 34 ms 208 KB # of queries: 2409
3 Correct 38 ms 208 KB # of queries: 2648
4 Correct 36 ms 208 KB # of queries: 2595
5 Correct 36 ms 208 KB # of queries: 2508
6 Correct 43 ms 280 KB # of queries: 2551
7 Correct 35 ms 220 KB # of queries: 2544
8 Correct 39 ms 292 KB # of queries: 2420
9 Correct 51 ms 284 KB # of queries: 2546
10 Correct 20 ms 208 KB # of queries: 1474
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 7
15 Correct 1 ms 288 KB # of queries: 77
16 Correct 3 ms 208 KB # of queries: 183
# Verdict Execution time Memory Grader output
1 Correct 33 ms 284 KB # of queries: 2375
2 Correct 34 ms 208 KB # of queries: 2409
3 Correct 38 ms 208 KB # of queries: 2648
4 Correct 36 ms 208 KB # of queries: 2595
5 Correct 36 ms 208 KB # of queries: 2508
6 Correct 43 ms 280 KB # of queries: 2551
7 Correct 35 ms 220 KB # of queries: 2544
8 Correct 39 ms 292 KB # of queries: 2420
9 Correct 51 ms 284 KB # of queries: 2546
10 Correct 20 ms 208 KB # of queries: 1474
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 7
15 Correct 1 ms 288 KB # of queries: 77
16 Correct 3 ms 208 KB # of queries: 183
17 Correct 459 ms 328 KB # of queries: 17982
18 Correct 386 ms 300 KB # of queries: 17293
19 Correct 423 ms 208 KB # of queries: 17467
20 Correct 383 ms 308 KB # of queries: 16325
21 Correct 389 ms 304 KB # of queries: 15324
22 Correct 523 ms 304 KB # of queries: 17669
23 Correct 459 ms 208 KB # of queries: 17224
24 Correct 166 ms 208 KB # of queries: 7915
25 Correct 476 ms 304 KB # of queries: 17136
26 Correct 463 ms 304 KB # of queries: 15963
27 Correct 176 ms 292 KB # of queries: 8040
28 Correct 414 ms 208 KB # of queries: 15957
29 Correct 433 ms 312 KB # of queries: 15939
30 Correct 428 ms 328 KB # of queries: 15957