Submission #995731

# Submission time Handle Problem Language Result Execution time Memory
995731 2024-06-09T20:16:14 Z MrAndria Library (JOI18_library) C++14
100 / 100
378 ms 692 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
//#define int long long
int l,r,n,t,m,mid,ans,sum,sum1,sum2,sum0,k,parent[1000005],a[1000005],b[1000005],d[4000005];
vector <int> v,v1,v2;
map <int,int> mp;
string s,s1;
bool b1;


// namespace {
// struct Judge
// {
// 	int N;
// 	int A[1002];
// 	int pos[1002];
// 	bool f[1002];
// 	int query_c;
// 	bool answered;
// 	void init()
// 	{
// 		query_c=0;
// 		int ret=scanf("%d",&N); ret++;
// 		answered=false;
// 		for(int i=0;i<N;i++)ret=scanf("%d",&A[i]),pos[A[i]]=i;
// 	}
// 	int query(const vector<int>& M)
// 	{
// 		if(query_c==20000)
// 		{
// 			puts("Wrong Answer [3]");
// 			exit(0);
// 		}
// 		if(int(M.size())!=N)
// 		{
// 			puts("Wrong Answer [1]");
// 			exit(0);
// 		}
// 		bool all_zero=true;
// 		for(int i=0;i<N;i++)
// 		{
// 			if(M[i]!=0&&M[i]!=1)
// 			{
// 				puts("Wrong Answer [2]");
// 				exit(0);
// 			}
// 			if(M[i]==1)all_zero=false;
// 		}
// 		if(all_zero)
// 		{
// 			puts("Wrong Answer [2]");
// 			exit(0);
// 		}
// 		memset(f,0,sizeof(f));
// 		for(int i=0;i<N;i++)if(M[i])f[pos[i+1]]=true;
// 		bool las=false;
// 		int r=0;
// 		for(int i=0;i<N;i++)
// 		{
// 			if(las==false&&f[i]==true)r++;
// 			las=f[i];
// 		}
// 		query_c++;
// 		return r;
// 	}
// 	void answer(const vector<int>& res)
// 	{
// 		bool f1=true,f2=true;
// 		if(int(res.size())!=N)
// 		{
// 			puts("Wrong Answer [4]");
// 			exit(0);
// 		}
// 		if(answered)
// 		{
// 			puts("Wrong Answer [7]");
// 			exit(0);
// 		}
// 		answered=true;
// 		memset(f,0,sizeof(f));
// 		for(int i=0;i<N;i++)
// 		{
// 			if(res[i]<=0||res[i]>N)
// 			{
// 				puts("Wrong Answer [5]");
// 				exit(0);
// 			}
// 			if(f[res[i]])
// 			{
// 				puts("Wrong Answer [6]");
// 				exit(0);
// 			}
// 			f[res[i]]=true;
// 		}
// 		for(int i=0;i<N;i++)
// 		{
// 			f1&=A[i]==res[i];
// 			f2&=A[i]==res[N-i-1];
// 		}
// 		if(!f1&&!f2)
// 		{
// 			puts("Wrong Answer [8]");
// 			exit(0);
// 		}
// 	}
// 	void end()
// 	{
// 		if(!answered)puts("Wrong Answer [7]");
// 		else printf("Accepted : %d\n",query_c);
// 	}
// }judge;
// }

// int Query(const vector<int>& M)
// {
// 	return judge.query(M);
// }
// void Answer(const vector<int>& res)
// {
// 	judge.answer(res);
// }
void Solve(int n){
        if(n==1){
            v.pb(1);
            Answer(v);
        }else{
for(int i=0;i<n;i++){
            v.pb(1);
            v1.pb(i+1);
        }
        for(int i=1;i<=n;i++){
            v[i-1]=0;
            if(Query(v)==1){
                k=i;
                break;

            }
            v[i-1]=1;
        }
        v2.pb(k);
        for(int i=2;i<=n;i++){
            // cout<<k<<endl;
            for(int j=0;j<v1.size();j++){
                if(k==v1[j]){
                    v1.erase(v1.begin()+j);
                    break;
                }
            }
            l=0;
            r=v1.size()-1;
            while(l<=r){
                mid=(l+r)/2;
                for(int j=0;j<v.size();j++){
                    v[j]=0;
                }
                for(int j=l;j<=mid;j++){
                    v[v1[j]-1]=1;
                }
                sum=Query(v);
                v[k-1]=1;
                if(sum==Query(v)){
                    r=mid;
                    ans=mid;
                    if(l==r){
                        break;
                    }
                }else{
                    l=mid+1;
                }
            }
            k=v1[ans];
            v2.pb(k);
        }
        Answer(v2);
        }
        
}
// int main()
// {
// 	judge.init();
// 	solve(judge.N);
// 	judge.end();
// }

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:147:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  147 |             for(int j=0;j<v1.size();j++){
      |                         ~^~~~~~~~~~
library.cpp:157:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  157 |                 for(int j=0;j<v.size();j++){
      |                             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 344 KB # of queries: 2625
2 Correct 23 ms 344 KB # of queries: 2665
3 Correct 21 ms 344 KB # of queries: 2874
4 Correct 22 ms 344 KB # of queries: 2803
5 Correct 27 ms 344 KB # of queries: 2740
6 Correct 34 ms 340 KB # of queries: 2795
7 Correct 34 ms 344 KB # of queries: 2812
8 Correct 22 ms 344 KB # of queries: 2614
9 Correct 37 ms 344 KB # of queries: 2746
10 Correct 17 ms 344 KB # of queries: 1646
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: 6
14 Correct 0 ms 340 KB # of queries: 11
15 Correct 1 ms 344 KB # of queries: 87
16 Correct 2 ms 344 KB # of queries: 217
# Verdict Execution time Memory Grader output
1 Correct 24 ms 344 KB # of queries: 2625
2 Correct 23 ms 344 KB # of queries: 2665
3 Correct 21 ms 344 KB # of queries: 2874
4 Correct 22 ms 344 KB # of queries: 2803
5 Correct 27 ms 344 KB # of queries: 2740
6 Correct 34 ms 340 KB # of queries: 2795
7 Correct 34 ms 344 KB # of queries: 2812
8 Correct 22 ms 344 KB # of queries: 2614
9 Correct 37 ms 344 KB # of queries: 2746
10 Correct 17 ms 344 KB # of queries: 1646
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: 6
14 Correct 0 ms 340 KB # of queries: 11
15 Correct 1 ms 344 KB # of queries: 87
16 Correct 2 ms 344 KB # of queries: 217
17 Correct 378 ms 688 KB # of queries: 19204
18 Correct 314 ms 344 KB # of queries: 18361
19 Correct 316 ms 428 KB # of queries: 18623
20 Correct 304 ms 436 KB # of queries: 17407
21 Correct 269 ms 592 KB # of queries: 16448
22 Correct 335 ms 440 KB # of queries: 18859
23 Correct 321 ms 444 KB # of queries: 18414
24 Correct 98 ms 428 KB # of queries: 8481
25 Correct 312 ms 440 KB # of queries: 18282
26 Correct 291 ms 432 KB # of queries: 17073
27 Correct 103 ms 344 KB # of queries: 8554
28 Correct 322 ms 692 KB # of queries: 17937
29 Correct 309 ms 592 KB # of queries: 17917
30 Correct 303 ms 436 KB # of queries: 17937