답안 #994966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994966 2024-06-08T08:56:32 Z Bula 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;
//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);
//}

vector<int> p, b;
int ask(int l, int r, int idx){
    //cout << l << " " << r << " " << idx << endl;
    l--, r--; idx--; for(int i = 0; i < p.size(); i++) p[i] = 0;
    for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
    if(idx > 0) p[idx] = 1;
    for(auto x : b) if(x > 0) p[x - 1] = 0;
    int ok = 0; 
    for(int i = 0; i < p.size(); i++) if(p[i]) ok = 1;
    if(!ok) return -1;
    //cout << Query(p) << endl;
    return Query(p);
}
void Solve(int n){
    p.resize(n);
    int cur = 1;
    for(int i = 1; i <= n; i++){
        b.push_back(i);
        if(ask(1, n, 0) == 1){
            cur = i; break;
        }
        b.clear();
    }
    b.clear();
    vector<int> ans = {cur};
    for(int i = 1; i <= n; i++){
        int l = 1, r = cur - 1, pas = 0;
        while(l < r){
            int m = (l + r) / 2;
            if(ask(1, m, cur) == ask(1, m, 0)) r = m;
            else l = m + 1;
        }
        if(l == r && ask(1, l, cur) == ask(1, l, 0)){
            ans.push_back(l); pas = l;
        }
        if(!pas){
            l = cur + 1, r = n;
            while(l < r){
                int m = (l + r + 1) / 2;
                if(ask(m, n, cur) == ask(m, n, 0)) l = m;
                else r = m - 1;
            }
            if(l == r && ask(l, n, cur) == ask(l, n, 0)){
                ans.push_back(l); pas = l;
            }
        }
        b.push_back(cur); cur = pas;
    }
    Answer(ans);
}

//int main()
//{
//	judge.init();
//	Solve(judge.N);
//	judge.end();
//}

Compilation message

library.cpp: In function 'int ask(int, int, int)':
library.cpp:119:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |     l--, r--; idx--; for(int i = 0; i < p.size(); i++) p[i] = 0;
      |                                     ~~^~~~~~~~~~
library.cpp:120:52: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
  120 |     for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
      |                                                    ^
In file included from /usr/include/c++/10/vector:60,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
library.cpp:120:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
  120 |     for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
      |                                                    ^
In file included from /usr/include/c++/10/vector:60,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
library.cpp:120:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
  120 |     for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from library.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
library.cpp:120:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  120 |     for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from library.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
library.cpp:120:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  120 |     for(int i = max(l, 1); i <= min(r, p.size() - 1); i++) p[i] = 1;
      |                                                    ^
library.cpp:124:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |     for(int i = 0; i < p.size(); i++) if(p[i]) ok = 1;
      |                    ~~^~~~~~~~~~