Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1e6+10;
struct node {
	int pos, val;
	bool operator < (node t) {
		if(pos == t.pos) return val < t.val;
		return pos < t.pos;
	}
};
bool operator < (node a, node b) {
	if(a.pos == b.pos) return a.val < b.val;
	return a.pos < b.pos;
}
int h, w;
int a[N], b[N];
set<node> s1;
multiset<int> s2;
int main() {
	cin>>h>>w;
	for(int i = 1;i <= h;i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for(int i = 1;i <= w;i++) {
		s1.insert({i, 0});
		s2.insert(0);
	}
	for(int i = 1;i <= h;i++) {
		vector<node> tmp;
		set<node>::iterator it = s1.lower_bound({a[i], 0});
		int val = INF;
		while(it != s1.end()&&it->pos <= b[i] + 1) {
			tmp.pb({it->pos, it->val});
			val = min(val, it->val + b[i] + 1 - it->pos);
			it++;
		}
		for(int i = 0;i < tmp.size();i++) {
			s1.erase(tmp[i]);
			s2.erase(tmp[i].val);
		}
		if(tmp.size() > 0&&[i] + 1 <= w) {
			s1.insert({b[i] + 1, val});
			s2.insert(val);
		}
		if(s1.size() == 0) cout<<"-1\n";
		else cout<<i + *s2.begin()<<"\n";
	}
	return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:68:40: error: expected '{' before '+' token
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                        ^
a.cc: In function 'int main()':
a.cc:68:40: error: no match for 'operator+' (operand types are 'main()::<lambda()>' and 'int')
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                    ~~~ ^ ~
      |                                    |     |
      |                                    |     int
      |                                    main()::<lambda()>
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'const _CharT*' and 'main()::<lambda()>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 3670 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3682 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3689 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3696 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3719 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'const _CharT*' and 'main()::<lambda()>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3726 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)'
 3733 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3733:5: note:   template argument deduction/substitution failed:
a.cc:68:42: note:   'main()::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   68 |                 if(tmp.size() > 0&&[i] + 1 <= w) {
      |                                          ^
/usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)'
 3740 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_st