Submission #1099159

#TimeUsernameProblemLanguageResultExecution timeMemory
1099159Lakshya108Snowball (JOI21_ho_t2)C++14
Compilation error
0 ms0 KiB
// https://oj.uz/problem/view/JOI21_ho_t2 // OI\JOI21\JOI21-Snowball.pdf #include <bits/stdc++.h> using namespace std; // Macros #define pb push_back #define pf push_front #define ff first #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define up(v) upper_bound(v) #define low(v) lower_bound(v) // #define rep(i, x, n) for(int i = x; i < n; ++i) // #define rrep(i, x, n) for(int i = x; i >= n; --i) // Read and Print #define read(a, n) for(ll i = 0; i < n; ++i) cin >> a[i]; #define print(a, n) for(ll i = 0; i < n; ++i){ cout << a[i] << " ";} cout << "\n"; #define endl "\n" #define sp " " // Typedefs typedef long long ll; typedef long double ld; typedef pair <ll, ll> pii; typedef vector <ll> vi; typedef vector <vector <ll>> vvi; using vec = vector<int>; // Constants const ll mxn = 1e6 + 5; const ll mod = 1e9 + 7; // Solve const ll N = 1e18; void solve() { ll n, ll q; vi a(n+2); a[0] = -N; a[n+1] = N; for(int i = 1; i<=n; i++) cin>>a[i]; vi m(q+1), pref(q+1); map<int, int> mp; mp[0] = 0; for(int i = 1; i<q; i++){ cin>>m[i]; prep[i] += pref[i-1] + m[i]; if(pref[i]>0){ auto it = mp.up(pref[i]); if(it==mp.end()) mp[pref[i]] = i; } else{ auto it = mp.low(pref[i]); if(it==mp.begin()) mp[pref[i]] = i; } } for(int i = 1; i<=n; i++){ int left = a[i], right = a[i]; int l = a[i-1], r = a[i]; while(r-l>1){ int mid = (l+r)/2; int x = mid - a[i]; int y = mid - a[i-1]; auto it1 = mp.up(x); if(it1 == mp.begin()){ l = mid; continue; } it1--; auto it2 = mp.low(y); if(it2 == mp.end()){ r = mid; continue; } if((it1->ss)<(it2->ss)) r=mid; else l = mid; } auto it1 = mp.up(r-1-a[i]); auto it2 = mp.low(r-a[i-1]); if(it1!=mp.begin()&&(it2==mp.end()||((--it1)->ss < it2->ss))) r--; left = r; l = a[i-1]; r = a[i]; while(r-l>1){ int mid = (l+r)/2; int x = mid - a[i]; int y = mid - a[i+1]; auto it1 = mp.low(x); if(it1 == mp.end()){ r = mid; continue; } auto it2 = mp.up(y); if(it2 == mp.begin()){ l = mid; continue; } it2--; if((it1->ss)<(it2->ss)) l=mid; else r = mid; } auto it1 = mp.low(l-1-a[i]); auto it2 = mp.up(l-a[i-1]); if(it1!=mp.end()&&(it2==mp.end()||(it1->ss < (--it2)->ss))) l++; right = l; } cout<<right - left <<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:43:14: error: expected initializer before 'q'
   43 |     ll n, ll q;
      |              ^
Main.cpp:48:10: error: 'q' was not declared in this scope
   48 |     vi m(q+1), pref(q+1);
      |          ^
Main.cpp:53:9: error: 'prep' was not declared in this scope; did you mean 'pref'?
   53 |         prep[i] += pref[i-1] + m[i];
      |         ^~~~
      |         pref
Main.cpp:109:14: error: conflicting declaration 'auto it1'
  109 |         auto it1 = mp.low(l-1-a[i]);
      |              ^~~
Main.cpp:84:14: note: previous declaration as 'std::_Rb_tree_iterator<std::pair<const int, int> > it1'
   84 |         auto it1 = mp.up(r-1-a[i]);
      |              ^~~
Main.cpp:110:14: error: conflicting declaration 'auto it2'
  110 |         auto it2 = mp.up(l-a[i-1]);
      |              ^~~
Main.cpp:85:14: note: previous declaration as 'std::_Rb_tree_iterator<std::pair<const int, int> > it2'
   85 |         auto it2 = mp.low(r-a[i-1]);
      |              ^~~
Main.cpp:114:17: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
  114 |     cout<<right - left <<endl;
      |           ~~~~~~^~~~~~