Submission #381223

# Submission time Handle Problem Language Result Execution time Memory
381223 2021-03-24T19:05:58 Z aryan12 Meteors (POI11_met) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
 
using namespace std;
 
vector<__int128> req;
vector<vector<__int128>> land;
vector<array<__int128, 3>> D;
vector<__int128> ans;
 
__int128 n, m;
 
struct BIT{
	vector<__int128> tree;
	__int128 n;
 
	void init(__int128 _n){
		n = _n;
		tree.resize(n+1);
	}
 
	void upd(__int128 idx, __int128 val){
		for(; idx <= n; idx += (idx&(-idx)))
			tree[idx] += val;
	}
 
	void upd(__int128 l, __int128 r, __int128 val){
		upd(l, val);
		upd(r+1, -val);
	}
 
	__int128 query(__int128 idx){
		__int128 sum = 0;
		for(; idx > 0; idx -= (idx&(-idx)))
			sum += tree[idx];
		return sum;
	}
 
}bit;
 
void PBS(__int128 l, __int128 r, vector<__int128> active){
	if(active.size() == 0)
		return;
 
	if(r - l == 1){
		for(__int128 i : active)
			ans[i] = l;
		return;
	}
 
	__int128 mid = (l + r) >> 1;
	
	for(__int128 i = l; i < mid; i++){
		if(D[i][0] <= D[i][1]) bit.upd(D[i][0], D[i][1], __int128(D[i][2]));
		else{
			bit.upd(D[i][0], m, __int128(D[i][2]));
			bit.upd(1, D[i][1], __int128(D[i][2]));
		}
	}
	
	vector<__int128> nq[2];
	
	for(__int128 i : active){
		__int128 sum = 0;
		for(__int128 v : land[i]) sum += bit.query(v);
		if(sum >= req[i]) nq[0].push_back(i);
		else{
			req[i] -= sum;
			nq[1].push_back(i);
		}
	}
 
	for(__int128 i = l; i < mid; i++){
		if(D[i][0] <= D[i][1]) bit.upd(D[i][0], D[i][1], __int128(-D[i][2]));
		else{
			bit.upd(D[i][0], m, __int128(-D[i][2]));
			bit.upd(1, D[i][1], __int128(-D[i][2]));
		}
	}
 
	PBS(l, mid, nq[0]);
	PBS(mid, r, nq[1]);
}
 
int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
 
	cin >> n >> m;
	land.resize(n+1), req.resize(n+1);
	ans.resize(n+1);
 
	bit.init(m);
 
	for(__int128 i = 1; i <= m; i++){
		__int128 x;
		cin >> x;
		land[x].push_back(i);
	}
 
	for(__int128 i = 1; i <= n; i++)
		cin >> req[i];
 
	__int128 k;
	cin >> k;
 
	D.resize(k+1);
	for(__int128 i = 1; i <= k; i++){
		auto& [l, r, upd] = D[i];
		cin >> l >> r >> upd;
	}
 
	vector<__int128> cur(n);
	iota(cur.begin(), cur.end(), 1);
	PBS(1, k+2, cur);
 
	for(__int128 i = 1; i <= n; i++)
		if(ans[i] == k+1) cout << "NIE\n";
		else cout << ans[i] << '\n';
 
	return 0; 
}

Compilation message

met.cpp: In function 'int32_t main()':
met.cpp:89:6: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__int128')
   89 |  cin >> n >> m;
      |  ~~~ ^~ ~
      |  |      |
      |  |      __int128
      |  std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  120 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:120:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
   89 |  cin >> n >> m;
      |         ^
      |         |
      |         __int128
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]' <near match>
  124 |       operator>>(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:124:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
   89 |  cin >> n >> m;
      |         ^
      |         |
      |         __int128
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:131:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  131 |       operator>>(ios_base& (*__pf)(ios_base&))
      |       ^~~~~~~~
/usr/include/c++/9/istream:131:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: invalid conversion from '__int128' to 'std::ios_base& (*)(std::ios_base&)' [-fpermissive]
   89 |  cin >> n >> m;
      |         ^
      |         |
      |         __int128
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:168:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' <near match>
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/9/istream:172:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'short int&' to an rvalue of type 'short int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:175:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:175:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to an rvalue of type 'short unsigned int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:179:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' <near match>
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/9/istream:179:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:182:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:182:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'unsigned int&' to an rvalue of type 'unsigned int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:186:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  186 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:186:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'long int&' to an rvalue of type 'long int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:190:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  190 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:190:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to an rvalue of type 'long unsigned int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:195:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  195 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:195:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  199 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/9/istream:199:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to an rvalue of type 'long long unsigned int'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:214:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  214 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/9/istream:214:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'float&' to an rvalue of type 'float'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:218:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  218 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/9/istream:218:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:222:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  222 |       operator>>(long double& __f)
      |       ^~~~~~~~
/usr/include/c++/9/istream:222:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: cannot bind non-const lvalue reference of type 'long double&' to an rvalue of type 'long double'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:235:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' <near match>
  235 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/9/istream:235:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: invalid conversion from '__int128' to 'void*' [-fpermissive]
   89 |  cin >> n >> m;
      |         ^
      |         |
      |         __int128
met.cpp:89:9: error: cannot bind rvalue '(void*)((long int)n)' to 'void*&'
In file included from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/istream:259:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]' <near match>
  259 |       operator>>(__streambuf_type* __sb);
      |       ^~~~~~~~
/usr/include/c++/9/istream:259:7: note:   conversion of argument 1 would be ill-formed:
met.cpp:89:9: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} [-fpermissive]
   89 |  cin >> n >> m;
      |         ^
      |         |
      |         __int128
met.cpp:89:6: note: candidate: 'operator>>(int, __int128)' <built-in>
   89 |  cin >> n >> m;
      |  ~~~~^~~~
met.cpp:89:6: note:   no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:45,
                 from met.cpp:1:
/usr/include/c++/9/cstddef:140:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(std::byte, _IntegerType)'
  140 |     operator>>(byte __b, _IntegerType __shift) noexcept
      |     ^~~~~~~~
/usr/include/c++/9/cstddef:140:5: note:   template argument deduction/substitution failed:
met.cpp:89:2: note:   cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
   89 |  cin >> n >> m;
      |  ^~~
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/include/c++/9/bits/basic_string.tcc:1466:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1466 |     operator>>(basic_istream<_CharT, _Traits>& __in,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1466:5: note:   template argument deduction/substitution failed:
met.cpp:89:9: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and '__int128'
   89 |  cin >> n >> m;
      |         ^
In file included from /usr/include/c++/9/istream:991,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from met.cpp:1:
/usr/includ