Submission #972845

# Submission time Handle Problem Language Result Execution time Memory
972845 2024-05-01T09:03:05 Z VinhLuu Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(lmao) lmao.begin(), lmao.end()

using namespace std;

typedef pair<int,int> pii;
typedef tuple<int,int,int> tp;
const int N = 1e6 + 5;
int block = 555;
const int mod = 1e9 + 7;
//const ll oo = 5e18;

int n, a[N];

vector<int> find_subset(int L,int R,vector<int> _w){
    vector<int> w;
    for(int i = 0; i < _w.size(); i ++) w.pb(i);
    sort(all(w), [&] (int x,int y){return _w[x] < _w[y];});
    for(int i = 0; i < w.size(); i ++){
        a[i] = w[i];
        w[i] = _w[i];
    }
    int ptr = 0;
    vector<int> ans;
    if(w[0] >= L && w[0] <= R){ans.pb(0); return ans;}
    deque<int> dq;
    int tmp = w[0];
    dq.pb(0);
    for(int i = 1; i < w.size(); i ++){
        dq.push_front(i);
        tmp += w[i];
        while(!dq.empty() && tmp > R){
            tmp -= w[dq.back()];
            dq.pop_back();
        }
        if(tmp >= L){
            while(!dq.empty()){
                ans.pb(dq.back());
                dq.pop_back();
            }
            sort(all(ans));
            return ans;
        }
    }
    return ans;
}

#define lpv
#ifdef lpv

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    #define task "v"
    if(fopen(task ".inp","r")){
        freopen(task ".inp","r",stdin);
        freopen(task ".out","w",stdout);
    }

    int l, u; cin >> l >> u;
    int x;
    vector<int> input;
    while (cin >> x) input.push_back(x);

    for (auto i : find_subset(l, u, input))
    cout << i << ' ';
}
#endif // lpv


Compilation message

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:24:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < _w.size(); i ++) w.pb(i);
      |                    ~~^~~~~~~~~~~
molecules.cpp:26:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < w.size(); i ++){
      |                    ~~^~~~~~~~~~
molecules.cpp:36:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 1; i < w.size(); i ++){
      |                    ~~^~~~~~~~~~
molecules.cpp:30:9: warning: unused variable 'ptr' [-Wunused-variable]
   30 |     int ptr = 0;
      |         ^~~
molecules.cpp: In function 'int main()':
molecules.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(task ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(task ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccUFa5wQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc2NyhJQ.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUFa5wQ.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status