제출 #850684

#제출 시각아이디문제언어결과실행 시간메모리
850684vjudge1A Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int N, int K, long long A, int S) { // TODO implement this function vector<long long> x(N+1); for(long long i = 1; i<= N; i++) x[i] = skim(i); vector<pair<long long,long long>> ans; vector<long long> in; map<long long,long long> idx; x[0] = x[1]; for(long long i = 0; i<=N; i++) idx[x[i]] = i; vector<long long> used(N+1); for(long long i = 1; i<=N; i++){ long long s = 2*A; s-=x[i]; long long a = *lower_bound(x.begin(),x.end(),s); if(x[i] + a <= 4*A && !used[i] && !used[idx[a]]) ans.push_back({min(idx[a],i),max(i,idx[a])}), used[i] = 1, used[idx[a]] =1; if(A <= x[i] && x[i] <= 2*A) in.push_back(i); } if(2*ans.size() < K - 1){ impossible(); return; } vector<long long> used1(N+1); vector<long long> ans1; for(long long i = 0; i<K/2; i++){ used1[ans[i].first] = used1[ans[i].second] = 1; ans1.push_back(ans[i].first); ans1.push_back(ans[i].second); } if(K%2 == 1){ for(long long i : in){ if(!used1[i]){ ans1.push_back(i); break; } } } if(ans1.size() != K) impossible(); else answer(ans1); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |   if(2*ans.size() < K - 1){
      |      ~~~~~~~~~~~~~^~~~~~~
books.cpp:49:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |   if(ans1.size() != K) impossible();
      |      ~~~~~~~~~~~~^~~~
books.cpp:50:15: error: could not convert 'ans1' from 'vector<long long int>' to 'vector<int>'
   50 |   else answer(ans1);
      |               ^~~~
      |               |
      |               vector<long long int>