Submission #874668

#TimeUsernameProblemLanguageResultExecution timeMemory
874668cpptowinDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define fo(i,d,c) for(int i=d;i<=c;i++) #define fod(i,c,d) for(int i=c;i>=d;i--) #define maxn 1000010 #define N 1010 #define fi first #define se second #define pb emplace_back #define en cout<<"\n"; #define int long long #define inf 1000000000 #define pii pair<int,int> #define vii vector<pii> #define lb(x) x&-x #define bit(i,j) ((i>>j)&1) #define offbit(i,j) (i^(1<<j)) #define onbit(i,j) (i|(1<<j)) #define vi vector<int> template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} using namespace std; int n; pii a[maxn]; int p[maxn]; int l,r; // unord main() { #define name "TASK" if(fopen(name".inp","r")) { freopen(name".inp","r",stdin); freopen(name".out","w",stdout); } ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n >> l >> r; fo(i,1,n) { cin >> a[i].fi; a[i].se = i; } sort(a + 1,a + n + 1); int sum = 0; fo(k,1,n) { sum += a[k].fi; while(sum > r and x <= k) { sum -= a[x].fi; x++; } if(sum >= l) { vi ans; for(int i = x ; i <= k ; i++) ans.pb(a[i].se); sort(ans.begin(),ans.end()); cout << ans.size() << "\n"; for(int it : ans) cout << it << ' '; return 0; } } }

Compilation message (stderr)

molecules.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main()
      | ^~~~
molecules.cpp: In function 'int main()':
molecules.cpp:47:27: error: 'x' was not declared in this scope
   47 |         while(sum > r and x <= k)
      |                           ^
molecules.cpp:55:25: error: 'x' was not declared in this scope
   55 |             for(int i = x ; i <= k ; i++) ans.pb(a[i].se);
      |                         ^
molecules.cpp:32:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |        freopen(name".inp","r",stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:33:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |        freopen(name".out","w",stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~