Submission #875708

#TimeUsernameProblemLanguageResultExecution timeMemory
875708nasir_bashirovDetecting Molecules (IOI16_molecules)C++11
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\

vi find_subset(int x, int y, int w) {
    vl org = w;
    sort(all(w));
    ll s = 0, l = 0;
    for(int i = 0; i < w.size(); i++){
        s += w[i];
        while(l < i and s > y){
            s -= w[l];
            l++;
        }
        if(s >= x and s <= y){
            vl res;
            map<ll, ll> cnt;
            for(int j = l; j <= i; j++) cnt[w[j]]++;
            for(int j = 0; j < w.size(); j++){
                if(cnt[org[j]]) res.push_back(j), cnt[org[j]]--;
            }
            return res;
        }
    } 
    vl res;
    return res;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, int)':
molecules.cpp:21:14: error: conversion from 'int' to non-scalar type 'std::vector<long long int>' requested
   21 |     vl org = w;
      |              ^
molecules.cpp:14:18: error: request for member 'begin' in 'w', which is of non-class type 'int'
   14 | #define all(x) x.begin(), x.end()
      |                  ^~~~~
molecules.cpp:22:10: note: in expansion of macro 'all'
   22 |     sort(all(w));
      |          ^~~
molecules.cpp:14:29: error: request for member 'end' in 'w', which is of non-class type 'int'
   14 | #define all(x) x.begin(), x.end()
      |                             ^~~
molecules.cpp:22:10: note: in expansion of macro 'all'
   22 |     sort(all(w));
      |          ^~~
molecules.cpp:24:26: error: request for member 'size' in 'w', which is of non-class type 'int'
   24 |     for(int i = 0; i < w.size(); i++){
      |                          ^~~~
molecules.cpp:25:15: error: invalid types 'int[int]' for array subscript
   25 |         s += w[i];
      |               ^
molecules.cpp:27:19: error: invalid types 'int[long long int]' for array subscript
   27 |             s -= w[l];
      |                   ^
molecules.cpp:33:46: error: invalid types 'int[int]' for array subscript
   33 |             for(int j = l; j <= i; j++) cnt[w[j]]++;
      |                                              ^
molecules.cpp:34:34: error: request for member 'size' in 'w', which is of non-class type 'int'
   34 |             for(int j = 0; j < w.size(); j++){
      |                                  ^~~~
molecules.cpp:37:20: error: could not convert 'res' from 'vector<long long int>' to 'vector<int>'
   37 |             return res;
      |                    ^~~
      |                    |
      |                    vector<long long int>
molecules.cpp:41:12: error: could not convert 'res' from 'vector<long long int>' to 'vector<int>'
   41 |     return res;
      |            ^~~
      |            |
      |            vector<long long int>