답안 #206815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206815 2020-03-05T13:33:11 Z vardan__02 Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include "molecules.h"
using namespace std;
typedef long long ll;
const long long N=200005;
#define MP make_pair
#define PB push_back
 
 vector<int> find_subset(int l, int u, std::vector<int> w)
 {
     vector<ll> ans;
     vector<pair<ll,ll> > a;
     ll n = w.size();
     for(ll i = 0; i < n; ++i)
        a.PB(MP(w[i],i));
     sort(a.begin(), a.end());
     ll left = 0, right = 0, tiv = 0;
     for(ll i = 0; i < n; ++i)
     {
         while(i < n && tiv < l)
         {
             tiv += a[i].first;
             i++;
         }
         i--;
         if(tiv < l)return ans;
         if(tiv <= u)
         {
             if(u - l >= a[i].first - a[left].first)
             {
                 for(ll j = left; j <= i; ++j)
                    ans.PB(a[j].second);
                 sort(ans.begin(), ans.end());
                 return ans;
             }
             else
             {
                 while(left <= i && u - l < a[i].first - a[left].first)
                 {
                     tiv -= a[left].first;
                     left++;
                 }
                 right = i;
             }
         }
         else
         {
             while(left <= i && tiv > u)
             {
                 tiv -= a[left].first;
                 left++;
             }
             while(left <= i && u - l < a[i].first - a[left].first)
             {
                 tiv -= a[left].first;
                 left++;
             }
             right = i;
         }
     }
     tiv = 0;
     for(ll i = left; i <= right; ++i)
        tiv += a[i].first;
     if(tiv >= l && tiv <= u && u - l >= a[right].first - a[left].first)
     {
         for(ll j = left; j <= right; ++j)
            ans.PB(a[j].second);
         sort(ans.begin(), ans.end());
         return ans;
     }
     else
        return ans;
 

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:38:28: error: could not convert 'ans' from 'std::vector<long long int>' to 'std::vector<int>'
          if(tiv < l)return ans;
                            ^~~
molecules.cpp:46:25: error: could not convert 'ans' from 'std::vector<long long int>' to 'std::vector<int>'
                  return ans;
                         ^~~
molecules.cpp:81:17: error: could not convert 'ans' from 'std::vector<long long int>' to 'std::vector<int>'
          return ans;
                 ^~~
molecules.cpp:84:16: error: could not convert 'ans' from 'std::vector<long long int>' to 'std::vector<int>'
         return ans;
                ^~~
molecules.cpp:84:19: error: expected '}' at end of input
         return ans;
                   ^