Compile Error
foo.cc: In function 'void work()':
foo.cc:28:20: error: expected identifier before 'this'
28 | auto res = [&](this auto &&res, int l, int r, int p) -> int {
| ^~~~
foo.cc:28:20: error: expected ',' or '...' before 'this'
foo.cc: In lambda function:
foo.cc:29:13: error: 'l' was not declared in this scope
29 | if (l == r) return v[l];
| ^
foo.cc:29:18: error: 'r' was not declared in this scope
29 | if (l == r) return v[l];
| ^
foo.cc:30:20: error: 'l' was not declared in this scope
30 | int mid = (l+r)/2;
| ^
foo.cc:30:22: error: 'r' was not declared in this scope
30 | int mid = (l+r)/2;
| ^
foo.cc:31:13: error: 'p' was not declared in this scope
31 | if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
| ^
foo.cc:31:27: error: use of 'res' before deduction of 'auto'
31 | if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
| ^~~
foo.cc:31:42: error: use of 'res' before deduction of 'auto'
31 | if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
| ^~~
foo.cc:32:25: error: use of 'res' before deduction of 'auto'
32 | else return min(res(l,mid,!p), res(mid+1,r,!p));
| ^~~
foo.cc:32:40: error: use of 'res' before deduction of 'auto'
32 | else return min(res(l,mid,!p), res(mid+1,r,!p));
| ^~~
foo.cc: In function 'void work()':
foo.cc:39:20: error: no match for call to '(work()::<lambda(int)>) (int, ll, ll&)'
39 | cout << res(0,n-1,p) << '\n';
| ~~~^~~~~~~~~
foo.cc:28:16: note: candidate: 'work()::<lambda(int)>'
28 | auto res = [&](this auto &&res, int l, int r, int p) -> int {
| ^
foo.cc:28:16: note: candidate expects 1 argument, 3 provided
Code
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
#define int ll
#define all(it) it.begin(),it.end()
#define ord_set(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
void work(){
int n,q;
cin >> n >> q;
vll v(n);
for (auto &c : v) cin >> c;
auto res = [&](this auto &&res, int l, int r, int p) -> int {
if (l == r) return v[l];
int mid = (l+r)/2;
if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
else return min(res(l,mid,!p), res(mid+1,r,!p));
};
for (int i=0;i<q;i++){
int a,b,p;
cin >> a >> b >> p;
v[a-1] = b;
cout << res(0,n-1,p) << '\n';
}
}
int32_t main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
work();
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1169 F. Thakur vs Roy again
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-04-07 00:24:54
- Judged At
- 2025-04-07 00:24:54
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes