/ SeriousOJ /

Record Detail

Compile Error

foo.cc:31:1: error: 'concept' does not name a type; did you mean 'const'?
   31 | concept Container = std::ranges::range<T> && requires { typename T::value_type; } && !same_as<T,string>;
      | ^~~~~~~
      | const
foo.cc:31:1: note: 'concept' only available with '-std=c++20' or '-fconcepts'
foo.cc:31:86: error: expected unqualified-id before '!' token
   31 | concept Container = std::ranges::range<T> && requires { typename T::value_type; } && !same_as<T,string>;
      |                                                                                      ^
foo.cc:32:11: error: 'Container' has not been declared
   32 | template <Container C>
      |           ^~~~~~~~~
foo.cc:33:34: error: 'C' has not been declared
   33 | istream& operator>>(istream& is, C& c) {
      |                                  ^
foo.cc: In function 'std::istream& operator>>(std::istream&, int&)':
foo.cc:34:23: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available [-fpermissive]
   34 |     for (auto& elem : c) is >> elem;
      |                       ^
foo.cc:34:23: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
foo.cc:34:23: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available [-fpermissive]
foo.cc: At global scope:
foo.cc:37:11: error: 'Container' has not been declared
   37 | template <Container C>
      |           ^~~~~~~~~
foo.cc:38:34: error: 'C' has not been declared
   38 | ostream& operator<<(ostream& os, C& c) {
      |                                  ^
foo.cc: In function 'std::ostream& operator<<(std::ostream&, int&)':
foo.cc:39:22: error: request for member 'begin' in 'c', which is of non-class type 'int'
   39 |     for (auto it = c.begin(); it != c.end(); it++) os << *it << (next(it) == c.end()?"":" ");
      |                      ^~~~~
foo.cc:39:39: error: request for member 'end' in 'c', which is of non-class type 'int'
   39 |     for (auto it = c.begin(); it != c.end(); it++) os << *it << (next(it) == c.end()?"":" ");
      |                                       ^~~
foo.cc:39:80: error: request for member 'end' in 'c', which is of non-class type 'int'
   39 |     for (auto it = c.begin(); it != c.end(); it++) os << *it << (next(it) == c.end()?"":" ");
      |                                                                                ^~~
foo.cc: In function 'void work()':
foo.cc:57:20: error: expected identifier before 'this'
   57 |     auto res = [&](this auto &&res, int l, int r, int p) -> int {
      |                    ^~~~
foo.cc:57:20: error: expected ',' or '...' before 'this'
foo.cc: In lambda function:
foo.cc:58:13: error: 'l' was not declared in this scope
   58 |         if (l == r) return v[l];
      |             ^
foo.cc:58:18: error: 'r' was not declared in this scope
   58 |         if (l == r) return v[l];
      |                  ^
foo.cc:59:20: error: 'l' was not declared in this scope
   59 |         int mid = (l+r)/2;
      |                    ^
foo.cc:59:22: error: 'r' was not declared in this scope
   59 |         int mid = (l+r)/2;
      |                      ^
foo.cc:60:13: error: 'p' was not declared in this scope
   60 |         if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
      |             ^
foo.cc:60:27: error: use of 'res' before deduction of 'auto'
   60 |         if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
      |                           ^~~
foo.cc:60:42: error: use of 'res' before deduction of 'auto'
   60 |         if (p) return max(res(l,mid,!p), res(mid+1,r,!p));
      |                                          ^~~
foo.cc:61:25: error: use of 'res' before deduction of 'auto'
   61 |         else return min(res(l,mid,!p), res(mid+1,r,!p));
      |                         ^~~
foo.cc:61:40: error: use of 'res' before deduction of 'auto'
   61 |         else return min(res(l,mid,!p), res(mid+1,r,!p));
      |                                        ^~~
foo.cc: In function 'void work()':
foo.cc:68:20: error: no match for call to '(work()::<lambda(int)>) (int, ll, ll&)'
   68 |         cout << res(0,n-1,p) << '\n';
      |                 ~~~^~~~~~~~~
foo.cc:57:16: note: candidate: 'work()::<lambda(int)>'
   57 |     auto res = [&](this auto &&res, int l, int r, int p) -> int {
      |                ^
foo.cc:57: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> 
  
template<class... T>
constexpr auto mmin(T... a){return min(initializer_list<common_type_t<T...>>{a...});}
template<class... T>
constexpr auto mmax(T... a){return max(initializer_list<common_type_t<T...>>{a...});}
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){return os<<p.first<<' '<<p.second;}
template<class t,class u>
istream& operator>>(istream& is,pair<t,u>& p){return is >> p.first >> p.second;}
template <typename T>
concept Container = std::ranges::range<T> && requires { typename T::value_type; } && !same_as<T,string>;
template <Container C>
istream& operator>>(istream& is, C& c) {
    for (auto& elem : c) is >> elem;
    return is;
}
template <Container C>
ostream& operator<<(ostream& os, C& c) {
    for (auto it = c.begin(); it != c.end(); it++) os << *it << (next(it) == c.end()?"":" ");
    return os;
}
template<class T, class... Ts>
void print(const T& a, const Ts&... b){
    cout << a;
    (cout << ... << (cout << ' ', b));
    cout << '\n';
}



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 Thakur vs Roy again
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-07 00:24:42
Judged At
2025-04-07 00:24:42
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes