Submission #397135

#TimeUsernameProblemLanguageResultExecution timeMemory
397135ak2006Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define ll long long #define vi vector<int> #define vvi vector<vi> vi find_subset(int l,int u,vi w) { int n = w.size(); vvi a(n,vi(2)); for (int i = 0;i<n;i++)a[i][0] = w[i],a[i][1] = i; sort(a.begin(),a.end()); ll sum = a[0][0],l = 0,r = 1; while (r <= n){ if (sum >= mn && sum <= mx)break; if (sum > mx){sum -= a[l][0];l++;} else {if (r == n)break;sum += a[r][0];r++;} if (sum >= mn && sum <= mx)break; } if (sum >= mn && sum <= mx){ vi ret; for (int i = l;i<r;i++)ret.push_back(a[i][1]); return ret; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:20: error: declaration of 'long long int l' shadows a parameter
   13 |   ll sum = a[0][0],l = 0,r = 1;
      |                    ^
molecules.cpp:15:16: error: 'mn' was not declared in this scope; did you mean 'n'?
   15 |     if (sum >= mn && sum <= mx)break;
      |                ^~
      |                n
molecules.cpp:15:29: error: 'mx' was not declared in this scope
   15 |     if (sum >= mn && sum <= mx)break;
      |                             ^~
molecules.cpp:16:15: error: 'mx' was not declared in this scope
   16 |     if (sum > mx){sum -= a[l][0];l++;}
      |               ^~
molecules.cpp:18:16: error: 'mn' was not declared in this scope; did you mean 'n'?
   18 |     if (sum >= mn && sum <= mx)break;
      |                ^~
      |                n
molecules.cpp:18:29: error: 'mx' was not declared in this scope
   18 |     if (sum >= mn && sum <= mx)break;
      |                             ^~
molecules.cpp:21:14: error: 'mn' was not declared in this scope; did you mean 'n'?
   21 |   if (sum >= mn && sum <= mx){
      |              ^~
      |              n
molecules.cpp:21:27: error: 'mx' was not declared in this scope
   21 |   if (sum >= mn && sum <= mx){
      |                           ^~