QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#437062#8768. Arrested DevelopmentUSP_USP_USP#Compile Error//C++233.4kb2024-06-09 04:51:342024-06-09 04:51:34

Judging History

你现在查看的是最新测评结果

  • [2024-06-09 04:51:34]
  • 评测
  • [2024-06-09 04:51:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define int ll

void dbg_out() { cerr << endl; }
template<typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }

constexpr double INF = 1e100;

constexpr int N = 3000;
namespace dsu {
	int n;
	int dad[N], sz[N];
	vector<tuple<int,int,int,int>> op;

	int find(int x) {
		while(x != dad[x]) x = dad[x];
		return x;
	}

	void join(int u, int v) {
		u = find(u);
		v = find(v);
		if(u == v) {
			op.emplace_back(-1, -1, -1, -1);
		} else {
			if(sz[u] > sz[v]) swap(u, v);
			op.emplace_back(u, v, dad[u], sz[u]);
			dad[u] = v;
			sz[v] += sz[u];
		}
	}

	void rollback() {
		assert(not op.empty());
		auto [u, v, dadu, szu] = op.back();
		op.pop_back();
		dad[u] = dadu;
		sz[u] = szu;
		sz[v] -= szu;
	}

	void init(int _n) {
		n = _n;
		iota(dad, dad + n, 0);
		fill_n(sz, n, 1);
	}
}

struct point {
	double x, y;
	point(): x(0), y(0) {}
	point(double _x, double _y): x(_x), y(_y) {}

	point operator+(point rhs) { return point(x+rhs.x, y+rhs.y); }
	point operator-(point rhs) { return point(x-rhs.x, y-rhs.y); }
	point operator*(double k) { return point(x*k, y*k); }
	point operator/(double k) { return point(x/k, y/k); }
	double operator*(point rhs) { return x*rhs.x + y*rhs.y; }
	double operator^(point rhs) { return x*rhs.y - y*rhs.x; }
};

struct segment {
	point a, b;
	segment() {}
	segment(point _a, point _b): a(_a), b(_b) {}

	point vec() return b - a; }
};

point line_intersection(segment r, segment s) {
	point vr = r.vec(), vs = s.vec();
	double cr = vr ^ r.a, cs = vs ^ s.a;
	return (vs * cr - vr * cs) / (vr ^ vs);
}

bool parallel(segment r, segment s) {
	point vr = r.vec(), vs = s.vec();
	return zero(vs ^ vr);
}

void solve() {
	int n, __w; cin >> n >> __w;

	vector<pair<point, point>> ranges(n);
	for(int i=0;i<n;i++) {
		int x, yl, yh;
		cin >> x >> yl >> yh;
		ranges[i].first = {x, yl};
		ranges[i].second = {x, yh};
	}

	auto check_unbounded = [&]() {
		const int M = 1'000'000;
		vector<int> s(2 * M + 1);
		for(auto &[a, b]: ranges) {
			int l = a.y + M, r = b.y + M;
			s[l]++;
			if(r + 1 <= 2 * M) s[r]--;
		}
		partial_sum(all(s));

		int fst = 0, lst = 2 * M;
		while(s[fst] == 0) fst++;
		while(s[lst] == 0) lst--;
		bool all_neq_0 = true;
		for(int i=fst; i <= lst; i++) if(s[i] == 0)
			all_neq_0 = false;
		return all_neq_0;
	};

	if(check_unbounded()) {
		cout << -1 << '\n';
		return;
	}

	dsu::init(n);

	struct event {
		double x;
		bool join;
		int u, v;
		event(double _x, bool _join, int _u, int _v): x(_x), join(_join), u(_u), v(_v) {}
	};

	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {
		if(ranges[i].first.x == ranges[j].first.x) continue;
		int min_x = min(ranges[i].first.x, ranges[j].first.x);
		int u = i, v = j;
		int ul = ranges[u].first.y, ur = ranges[u].second.y;
		int vl = ranges[v].first.y, vr = ranges[v].second.y;
		if(ul  > vl) {
			swap(u, v);
			swap(ul, vl);
			swap(ur, vr);
		}

		segment r(ranges[u].first, ranges[v].second);
		segment s(ranges[u].second, ranges[v].first);
		segment y0(point(0, 0), point(1, 0));
		double rx = parallel(r, y0) ? HUGE_VAL : line_intersection(r, y0).x,
		double sx = parallel(s, y0) ? HUGE_VAL : line_intersection(s, y0).x,
	}

	sort(all(event));
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	solve();
}

详细

answer.code:74:36: error: expected ‘;’ after struct definition
   74 |         point vec() return b - a; }
      |                                    ^
      |                                    ;
answer.code: In member function ‘point segment::vec()’:
answer.code:74:21: error: named return values are no longer supported
   74 |         point vec() return b - a; }
      |                     ^~~~~~
answer.code:74:33: error: expected ‘{’ at end of input
   74 |         point vec() return b - a; }
      |                                 ^
answer.code:74:33: warning: no return statement in function returning non-void [-Wreturn-type]
answer.code: At global scope:
answer.code:75:1: error: expected declaration before ‘}’ token
   75 | };
      | ^
answer.code: In function ‘bool parallel(segment, segment)’:
answer.code:85:16: error: ‘zero’ was not declared in this scope; did you mean ‘bzero’?
   85 |         return zero(vs ^ vr);
      |                ^~~~
      |                bzero
answer.code: In function ‘void solve()’:
answer.code:95:36: warning: narrowing conversion of ‘x’ from ‘ll’ {aka ‘long long int’} to ‘double’ [-Wnarrowing]
   95 |                 ranges[i].first = {x, yl};
      |                                    ^
answer.code:95:39: warning: narrowing conversion of ‘yl’ from ‘ll’ {aka ‘long long int’} to ‘double’ [-Wnarrowing]
   95 |                 ranges[i].first = {x, yl};
      |                                       ^~
answer.code:96:37: warning: narrowing conversion of ‘x’ from ‘ll’ {aka ‘long long int’} to ‘double’ [-Wnarrowing]
   96 |                 ranges[i].second = {x, yh};
      |                                     ^
answer.code:96:40: warning: narrowing conversion of ‘yh’ from ‘ll’ {aka ‘long long int’} to ‘double’ [-Wnarrowing]
   96 |                 ranges[i].second = {x, yh};
      |                                        ^~
answer.code: In lambda function:
answer.code:107:28: error: no matching function for call to ‘partial_sum(std::vector<long long int>::iterator, std::vector<long long int>::iterator)’
  107 |                 partial_sum(all(s));
      |                 ~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/13/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_numeric.h:256:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator> constexpr _OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator)’
  256 |     partial_sum(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:256:5: note:   template argument deduction/substitution failed:
answer.code:107:28: note:   candidate expects 3 arguments, 2 provided
  107 |                 partial_sum(all(s));
      |                 ~~~~~~~~~~~^~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:298:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation> constexpr _OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation)’
  298 |     partial_sum(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:298:5: note:   template argument deduction/substitution failed:
answer.code:107:28: note:   candidate expects 4 arguments, 2 provided
  107 |                 partial_sum(all(s));
      |                 ~~~~~~~~~~~^~~~~~~~
answer.code: In function ‘void solve()’:
answer.code:148:17: error: expected unqualified-id before ‘double’
  148 |                 double sx = parallel(s, y0) ? HUGE_VAL : line_intersection(s, y0).x,
      |                 ^~~~~~
answer.code:5:18: error: expected primary-expression before ‘)’ token
    5 | #define all(v) (v).begin(), (v).end()
      |                  ^
answer.code:151:14: note: in expansion of macro ‘all’
  151 |         sort(all(event));
      |              ^~~
answer.code:5:31: error: expected primary-expression before ‘)’ token
    5 | #define all(v) (v).begin(), (v).end()
      |                               ^
answer.code:151:14: note: in expansion of macro ‘all’
  151 |         sort(all(event));
      |              ^~~