Submission #872473

#TimeUsernameProblemLanguageResultExecution timeMemory
872473karimovDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); #define fio(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout) void YES(bool t=1){std::cout<<(t?"YES\n":"NO\n");} void NO(bool t=1){YES(!t);} const int MOD = 1000000007; #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); int sum=0,left=1,right=1; vector<int> arr(n+1); arr[0]=0; for(int i = 1; i < n+1; i++) { arr[i] = arr[i-1]+w[i-1]; } vector<int>ans; while(right < n) { int x = arr[right]-arr[left-1]; // cout << x << endl; if(x < l)right++; else if(x > u)left++; if(x >= l && x <= u) { for(int i = left; i <= right; i++) { ans.pb(i); } break; } if(left > right)right++; } return ans; } void solve() { int n,l,u; cin >> n >> l >> u; vector<int> arr(n); for(auto &it:arr)cin>>it; vector<int> v = find_subset(l,u,arr); for(auto it : v) cout << it << " " ; } int main() { FAST solve(); return 0; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:6: warning: unused variable 'sum' [-Wunused-variable]
   14 |  int sum=0,left=1,right=1;
      |      ^~~
/usr/bin/ld: /tmp/ccny1Fyt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccvFpScr.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status