Submission #898100

#TimeUsernameProblemLanguageResultExecution timeMemory
898100LitusianoHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' struct MST{ int n; vector<vector<int>> seg; void init(int n1){ n = 1; while(n < n1) n*=2; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,q; cin>>n>>q; vector<int> v(n); for(int& i : v) cin>>i; for(int i = 1; i<n; i++){ pre[i+1] = pre[i] + (v[i] < v[i-1]); } while(q--){ int l,r,k; cin>>l>>r>>k; if(n > 600){ if(pre[r] - pre[l] == 0) cout<<1<<endl; else cout<<0<<endl; } else{ int mx = 0; for(int i = l; i <= r; i++){ for(int j = i+1; j<=r; j++){ if(v[i] > v[j]) mx = max(mx,v[i] + v[j]); // ill have to swap them } } if(mx > k) cout<<0<<endl; else cout<<1<<endl; } } }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:22:4: error: 'pre' was not declared in this scope
   22 |    pre[i+1] = pre[i] + (v[i] < v[i-1]);
      |    ^~~
sortbooks.cpp:27:8: error: 'pre' was not declared in this scope
   27 |     if(pre[r] - pre[l] == 0) cout<<1<<endl;
      |        ^~~