QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296429#5067. Two WallszzuqyCompile Error//C++142.9kb2024-01-03 01:42:502024-01-03 01:42:50

Judging History

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

  • [2024-01-03 01:42:50]
  • 评测
  • [2024-01-03 01:42:50]
  • 提交

answer

#include <bits/stdc++.h>
#define EPS 1e-8
#define double long double
struct Vector {
	long long x, y;
	inline Vector() {

	}
	inline Vector(long long x, long long y) {
		this->x = x;
		this->y = y;
	}
	inline Vector operator - (const Vector &a)const {
		return (Vector) {
			x - a.x, y - a.y
		};
	}
	inline long long operator * (const Vector &a)const {
		return x * a.x + y * a.y;
	}
	inline long long operator ^ (const Vector &a)const {
		return x * a.y - y * a.x;
	}
	inline double dis() {
		return std::sqrt(x * x + y * y);
	}
	inline int operator == (Vector a) {
		return a.x == x && a.y == y;
	}
};

inline int sign(long long a) {
	if (a == 0)
		return 0;
	return a > 0 ? 1 : -1;
}

inline int in(Vector a, Vector p, Vector q) {
	return ((p - a) * (q - a)) < 0;
}

inline int check(Vector a, Vector b, Vector c, Vector d) {
	if (!sign((d - c) ^ (b - a))) {
		if (in(a, c, d) || in(b, c, d) || in(c, a, b) || in(d, a, b)) {
			return 1;
		}
		return 0;
	}
	int cc = sign((c - a) ^ (c - b));
	int dd = sign((d - a) ^ (d - b));
	int aa = sign((a - c) ^ (a - d));
	int bb = sign((b - c) ^ (b - d));
	return  cc != dd &&  aa != bb;
}

inline double dis(Vector x, Vector a, Vector b) {
	double len = (a - b) * (x - b) / std::sqrt((a - b).dis());
	return (x - b).dis() - len * len ;
}

int main() {
	int $;
	scanf("%d", &$);
	while ($--) {
		Vector a;
		Vector b;
		Vector c1;
		Vector c2;
		Vector d1;
		Vector d2;
		scanf("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld",
		      &a.x, &a.y, &b.x, &b.y, &c1.x, &c1.y, &c2.x, &c2.y, &d1.x, &d1.y, &d2.x, &d2.y);
		if (!check(a, b, c1, c2) && !check(a, b, d1, d2)) {
			puts("0");
		} else if (c1 == d1 || c2 == d1 || c1 == d2 || c2 == d2) {
			puts("1");
		} else if (!sign((d2 - d1) ^ (c2 - c1))) {
			puts("1");
		} else if (!check(c1, c2, d1, d2)) {
			puts("1");
		} else if (check(a, b, c1, c2) + check(a, b, d1, d2) == 1) {
			puts("1");
		} else if (!sign((b - a) ^ (c2 - c1)) || !sign((b - a) ^ (d2 - d1))) {
			puts("1");
		} else {
			Vector a0(0, 0), a1(0, 0);
			Vector b0(0, 0), b1(0, 0);
			if (!check(a, c1, d1, d2)) {
				a0 = c1;
			} else {
				a0 = c2;
			}
			if (!check(a, d1, c1, c2)) {
				a1 = d1;
			} else {
				a1 = d2;
			}
			if (!check(b, c1, d1, d2)) {
				b0 = c1;
			} else {
				b0 = c2;
			}
			if (!check(b, d1, c1, c2)) {
				b1 = d1;
			} else {
				b1 = d2;
			}
//			printf("%lf %lf %lf %lf\n", dis(a, b, b1), dis(a0, b, b1), dis(a, b, b0), dis(a1, b, b0));
			int ans=2;
			if(!sign((b-a)^(a0-b)))ans=2;
			else if (((double)((b - a) * (a0 - a))) /  (a0 - a).dis() > EPS+((double)((b - a) * (b1 - b))) / 
			        (b1 - b).dis())ans=1;
			if(!sign((b-a)^(a1-b0)))ans=min(ans,2);
			else if(((double)((b - a) * (a1 - a))) / (a1 - a).dis() > EPS+((double)((b - a) * (b0 - b))) /
			        (b0 - b).dis())ans=min(ans,1);
			printf("%d\n",ans);
		}
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:113:53: error: ‘min’ was not declared in this scope; did you mean ‘std::min’?
  113 |                         if(!sign((b-a)^(a1-b0)))ans=min(ans,2);
      |                                                     ^~~
      |                                                     std::min
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
answer.code:115:52: error: ‘min’ was not declared in this scope; did you mean ‘std::min’?
  115 |                                 (b0 - b).dis())ans=min(ans,1);
      |                                                    ^~~
      |                                                    std::min
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
answer.code:63:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   63 |         scanf("%d", &$);
      |         ~~~~~^~~~~~~~~~
answer.code:71:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   71 |                 scanf("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld",
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 |                       &a.x, &a.y, &b.x, &b.y, &c1.x, &c1.y, &c2.x, &c2.y, &d1.x, &d1.y, &d2.x, &d2.y);
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~