Submission #522912

# Submission time Handle Problem Language Result Execution time Memory
522912 2022-02-06T12:39:10 Z dostigator Simple game (IZhO17_game) C++14
Compilation error
0 ms 0 KB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
#define IShowSpeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcnt __builtin_popcount
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define mii map<int,int>
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define pb push_back
#define vt vector
#define endl '\n'
#define X first
#define Y second
typedef long double ld;
typedef long long ll;
const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=1e6+10;
const ll mod=1e9+7,inf=1e18;
int n,q,y[N],t[4*N];
void upd(int v, int tl, int tr, int l, int r, int val) {
	if(tl >= l && tr <= r) {
		t[v] += val;
		return;
	}
	if(tl > r || l > tr)
		return;
	int mid = (tl + tr) >> 1;
	upd(v * 2, tl, mid, l, r, val);
	upd(v * 2 + 1, mid + 1, tr, l, r, val);
}

int get(int v, int tl, int tr, int id, int res) {
	res += t[v];
	if(tl == tr)
		return res;
	int mid = (tl + tr) >> 1;
	if(id <= mid)
		return get(v * 2, tl, mid, id, res);
	else
		return get(v * 2 + 1, mid + 1, tr, id, res);
}
void solve(){
    cin>>n>>q;
	for(int i=1; i<=n; ++i) cin>>y[i];
	for(int i=1; i<n; ++i) {
		int l=min(y[i],y[i+1]),r=max(y[i],y[i+1]);
		upd(l,r,1);
	}
	while(q--){
		int tp;
		cin>>tp;
		int i,d;
		if(tp==1) {
			cin>>i>>d;
			if(i<n){
				int l=min(y[i],y[i+1]),r=max(y[i],y[i+1]);
				upd(l,r,-1);
			}
			if(i>1) {
				int l=min(y[i],y[i-1]),r=max(y[i],y[i-1]);
				upd(l,r,-1);
			}
			y[i]=d;
			if(i<n){
				int l=min(y[i],y[i+1]),r=max(y[i],y[i+1]);
				upd(l,r,1);
			}
			if(i>1){
				int l=min(y[i],y[i-1]),r=max(y[i],y[i-1]);
				upd(l,r,1);
			}
		}
		else{
			cin>>d;
			cout<<get(d,0)<<endl;
		}
	}
}
int main() {
    IShowSpeed;
    int tt=1;
    //cin>>tt;
    while(tt--) solve();
}

Compilation message

game.cpp: In function 'void solve()':
game.cpp:49:12: error: too few arguments to function 'void upd(int, int, int, int, int, int)'
   49 |   upd(l,r,1);
      |            ^
game.cpp:22:6: note: declared here
   22 | void upd(int v, int tl, int tr, int l, int r, int val) {
      |      ^~~
game.cpp:59:15: error: too few arguments to function 'void upd(int, int, int, int, int, int)'
   59 |     upd(l,r,-1);
      |               ^
game.cpp:22:6: note: declared here
   22 | void upd(int v, int tl, int tr, int l, int r, int val) {
      |      ^~~
game.cpp:63:15: error: too few arguments to function 'void upd(int, int, int, int, int, int)'
   63 |     upd(l,r,-1);
      |               ^
game.cpp:22:6: note: declared here
   22 | void upd(int v, int tl, int tr, int l, int r, int val) {
      |      ^~~
game.cpp:68:14: error: too few arguments to function 'void upd(int, int, int, int, int, int)'
   68 |     upd(l,r,1);
      |              ^
game.cpp:22:6: note: declared here
   22 | void upd(int v, int tl, int tr, int l, int r, int val) {
      |      ^~~
game.cpp:72:14: error: too few arguments to function 'void upd(int, int, int, int, int, int)'
   72 |     upd(l,r,1);
      |              ^
game.cpp:22:6: note: declared here
   22 | void upd(int v, int tl, int tr, int l, int r, int val) {
      |      ^~~
game.cpp:77:17: error: no matching function for call to 'get(int&, int)'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
game.cpp:34:5: note: candidate: 'int get(int, int, int, int, int)'
   34 | int get(int v, int tl, int tr, int id, int res) {
      |     ^~~
game.cpp:34:5: note:   candidate expects 5 arguments, 2 provided
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)'
  223 |     get(std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:223:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)'
  228 |     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:228:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)'
  233 |     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:233:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)'
  238 |     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:238:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)'
  247 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:247:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)'
  252 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:252:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)'
  257 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:257:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)'
  262 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:262:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)'
  267 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:267:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)'
  272 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:272:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)'
  277 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:277:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:3:
/usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)'
  282 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:282:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)'
  334 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:334:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)'
  343 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:343:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)'
  351 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:351:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)'
  360 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:360:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)'
 1294 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1294:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)'
 1300 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1300:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)'
 1306 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1306:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const std::tuple<_Elements ...>&&)'
 1315 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1315:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)'
 1338 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1338:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)'
 1344 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1344:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)'
 1350 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1350:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:3:
/usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_Elements ...>&&)'
 1357 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1357:5: note:   template argument deduction/substitution failed:
game.cpp:77:17: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   77 |    cout<<get(d,0)<<endl;
      |                 ^