Submission #1141332

#TimeUsernameProblemLanguageResultExecution timeMemory
1141332harry_tm_18Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5; vector<int> adj[N]; vector<bool> c(N); vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<ll,ll>> a; for(int i=0; i<n; ++i){ a.emplace_back(w[i],i); } sort(a.begin(), a.end()); vector<ll> suffix(n), ans; suffix[n-1] = a[n-1].first; for(int i=n-2; i>=0; --i){ suffix[i] = suffix[i+1] + a[i].first; } ll prefixSum = 0; for(int i=0; i<n; ++i){ if(prefixSum > u) break; if(prefixSum <= l){ for(int j=0; j<=i; ++i){ ans.push_back(a[j].second); } return ans; } ll v = 0, g = n-1; while(v <= g){ int mid = v + (g - v) / 2; if(prefixSum + suffix[mid] >= l && prefixSum + suffix[mid] <= u){ for(int j=0; j<i; ++j){ ans.push_back(a[j].second); } for(int j=mid+1; j<n; ++j){ ans.push_back(a[j].second); } return ans; } else if(prefixSum + suffix[mid] > u){ v = mid + 1; } else { g = mid - 1; } } prefixSum += a[i].first; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:35:20: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   35 |             return ans;
      |                    ^~~
      |                    |
      |                    vector<long long int>
molecules.cpp:50:24: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   50 |                 return ans;
      |                        ^~~
      |                        |
      |                        vector<long long int>
molecules.cpp:60:12: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   60 |     return ans;
      |            ^~~
      |            |
      |            vector<long long int>
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~