Submission #709578

# Submission time Handle Problem Language Result Execution time Memory
709578 2023-03-13T23:48:51 Z GusterGoose27 Treatment Project (JOI20_treatment) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int MAXN = 1e5;
const int inf = 1e6;
int t, n;
pii points[2*MAXN];
int cost[MAXN];
vector<int> snodes;
vector<int> enodes;
int xsort[2*MAXN];
int ysort[2*MAXN];
int xinv[2*MAXN];
int yinv[2*MAXN];
ll dist[2*MAXN];

struct compx {
	bool operator()(int a, int b) {
		pii compa = pii(-points[a].first, points[a].second);
		pii compb = pii(-points[b].first, points[b].second);
		return compa == compb ? (b & 1) : compa < compb;
	}
} compx;

struct compy {
	bool operator()(int a, int b) {
		pii compa = pii(points[a].second, -points[a].first);
		pii compb = pii(points[b].second, -points[b].first);
		return compa == compb ? (b & 1) : compa < compb;
	}
} compy;

class stree {
public:
	int lp, rp;
	stree *l = nullptr;
	stree *r = nullptr;
	int mn; // min by y
	stree(int lv, int rv) {
		lp = lv;
		rp = rv;
		if (lp < rp) {
			int mid = (lp+rp)/2;
			l = new stree(lp, mid);
			r = new stree(mid+1, rp);
			mn = min(l->mn, r->mn);
		}
		else mn = yinv[xsort[lp]];
	}
	int get_mn(int lv, int rv) { // returns position of element in ysort/2
		if (lp > rv || rp < lv) return inf;
		if (lp >= lv && rp <= rv) return mn;
		return min(l->get_mn(lv, rv), r->get_mn(lv, rv));
	}
	void del(int p) { // position of element in xsort
		if (lp > p || rp < p) return;
		if (lp == rp) {
			mn = inf;
			return;
		}
		l->del(p);
		r->del(p);
		mn = min(l->mn, r->mn);
	}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> t >> n;
	for (int i = 0; i < n; i++) {
		int x, y1, y2;
		cin >> x >> y1 >> y2 >> cost[i];
		if (y1 == 1) snodes.push_back(i);
		if (y2 == t) enodes.push_back(i);
		points[2*i] = pii(x-y1, x+y1);
		points[2*i+1] = pii(x-y2-1, x+y2+1);
	}
	while (points[0]&1) n++;
	iota(xsort, xsort+2*n, 0);
	iota(ysort, ysort+2*n, 0);
	sort(xsort, xsort+2*n, compx);
	sort(ysort, ysort+2*n, compy);
	for (int i = 0; i < 2*n; i++) {
		xinv[xsort[i]] = i;
		yinv[ysort[i]] = i;
	}
	priority_queue<pli, vector<pli>, greater<pli>> pq;
	stree *tree = new stree(0, 2*n-1);
	fill(dist, dist+2*n, -1);
	for (int v: snodes) {
		dist[v] = cost[v];
		pq.push(pli(cost[v], v));
		tree->del(xinv[2*v]);
		tree->del(xinv[2*v+1]);
	}
	while (!pq.empty()) {
		pli tp = pq.top();
		pq.pop();
		int xpos = xinv[2*tp.second+1]-1;
		int ypos = yinv[2*tp.second+1]-1;
		int curv;
		while ((curv = tree->get_mn(0, xpos)) <= ypos) {
			curv = ysort[curv];
			curv /= 2;
			tree->del(xinv[2*curv]);
			tree->del(xinv[2*curv+1]);
			dist[curv] = dist[tp.second]+cost[curv];
			pq.push(pli(dist[curv], curv));
		}
	}
	ll ans = -1;
	for (int v: enodes) {
		if ((dist[v] != -1) && (ans == -1 || dist[v] < ans)) ans = dist[v];
	}
	cout << ans << '\n';
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:83:18: error: no match for 'operator&' (operand types are 'pii' {aka 'std::pair<int, int>'} and 'int')
   83 |  while (points[0]&1) n++;
      |         ~~~~~~~~~^~
      |                 | |
      |                 | int
      |                 pii {aka std::pair<int, int>}
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from treatment.cpp:1:
/usr/include/c++/10/cstddef:138:3: note: candidate: 'constexpr std::byte std::operator&(std::byte, std::byte)'
  138 |   operator&(byte __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/cstddef:138:18: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::byte'
  138 |   operator&(byte __l, byte __r) noexcept
      |             ~~~~~^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/ios_base.h:83:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator&(std::_Ios_Fmtflags, std::_Ios_Fmtflags)'
   83 |   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:83:27: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::_Ios_Fmtflags'
   83 |   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:125:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator&(std::_Ios_Openmode, std::_Ios_Openmode)'
  125 |   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:125:27: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::_Ios_Openmode'
  125 |   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:165:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator&(std::_Ios_Iostate, std::_Ios_Iostate)'
  165 |   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:165:26: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::_Ios_Iostate'
  165 |   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
      |             ~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
                 from treatment.cpp:1:
/usr/include/c++/10/bitset:1435:5: note: candidate: 'template<long unsigned int _Nb> std::bitset<_Nb> std::operator&(const std::bitset<_Nb>&, const std::bitset<_Nb>&)'
 1435 |     operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/10/bitset:1435:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::bitset<_Nb>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/c++/10/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/10/memory:85,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:82,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/atomic_base.h:100:3: note: candidate: 'constexpr std::memory_order std::operator&(std::memory_order, std::__memory_order_modifier)'
  100 |   operator&(memory_order __m, __memory_order_modifier __mod)
      |   ^~~~~~~~
/usr/include/c++/10/bits/atomic_base.h:100:26: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::memory_order'
  100 |   operator&(memory_order __m, __memory_order_modifier __mod)
      |             ~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/valarray:1191:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const std::valarray<_Tp>&, const std::valarray<_Tp>&)'
 1191 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1191:1: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::valarray<_Tp>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/valarray:1191:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)'
 1191 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1191:1: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   'pii' {aka 'std::pair<int, int>'} is not derived from 'const std::valarray<_Tp>'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from treatment.cpp:1:
/usr/include/c++/10/valarray:1191:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)'
 1191 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1191:1: note:   template argument deduction/substitution failed:
treatment.cpp:83:19: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   83 |  while (points[0]&1) n++;
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:105,
                 from treatment.cpp:1:
/usr/include/c++/10/future:143:20: note: candidate: 'constexpr std::launch std::operator&(std::launch, std::launch)'
  143 |   constexpr launch operator&(launch __x, launch __y)
      |                    ^~~~~~~~
/usr/include/c++/10/future:143:37: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::launch'
  143 |   constexpr launch operator&(launch __x, launch __y)
      |                              ~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:127,
                 from treatment.cpp:1:
/usr/include/c++/10/charconv:668:3: note: candidate: 'constexpr std::chars_format std::operator&(std::chars_format, std::chars_format)'
  668 |   operator&(chars_format __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/charconv:668:26: note:   no known conversion for argument 1 from 'pii' {aka 'std::pair<int, int>'} to 'std::chars_format'
  668 |   operator&(chars_format __lhs, chars_format __rhs) noexcept
      |             ~~~~~~~~~~~~~^~~~~