Submission #2113353


Source Code Expand

#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define ps(x) printf("%s", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

struct Point {
	LL xs, ys, xe, ye;
	Point(LL _xs, LL _ys, LL _xe, LL _ye) {
		if(_xs < _xe) {
			xs = _xs;
			ys = _ys;
			xe = _xe;
			ye = _ye;
		}
		else {
			xs = _xe;
			ys = _ye;
			xe = _xs;
			ye = _ys;
		}
	}
};

bool intersect(Point fi, Point sec) {
	LL a = (sec.ye - sec.ys);
	LL b = (sec.xs - sec.xe);
	LL c = sec.ys * (sec.xe - sec.xs) - sec.xs * (sec.ye - sec.ys);
	LL st = a * fi.xs + b * fi.ys + c;
	LL en = a * fi.xe + b * fi.ye + c;
	return (st * en < 0);
}

int main() {
	sll(Y); sll(X); sll(n);
	vector<Point> ps;
	rep(i, 0, n) {
		sll(xs); sll(ys); sll(xe); sll(ye);
		if(((xs == 0 || xs == X) || (ys == 0 || ys == Y)) && ((xe == 0 || xe == X) || (ye == 0 || ye == Y)))
			ps.push_back(Point(xs, ys, xe, ye));
	}
	rep(i, 0, ps.size()) {
		rep(j, i+1, ps.size()) {
			if(intersect(ps[i], ps[j])) {
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	return 0;
}

Submission Info

Submission Time
Task E - Connected?
User vjudge3
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2436 Byte
Status WA
Exec Time 28 ms
Memory 2420 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 26
WA × 12
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 43.txt, 44.txt, 45.txt, 46.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt WA 24 ms 1400 KB
02.txt WA 26 ms 1400 KB
03.txt WA 26 ms 1400 KB
04.txt WA 26 ms 640 KB
05.txt WA 27 ms 1400 KB
06.txt WA 25 ms 2420 KB
07.txt AC 28 ms 512 KB
08.txt AC 26 ms 1400 KB
09.txt AC 27 ms 892 KB
10.txt AC 26 ms 1400 KB
11.txt AC 26 ms 1400 KB
12.txt WA 27 ms 256 KB
13.txt WA 27 ms 640 KB
14.txt AC 24 ms 1400 KB
15.txt AC 27 ms 1400 KB
16.txt WA 28 ms 384 KB
17.txt WA 28 ms 256 KB
18.txt WA 27 ms 256 KB
19.txt AC 27 ms 892 KB
20.txt AC 26 ms 2420 KB
21.txt AC 27 ms 892 KB
22.txt AC 27 ms 1400 KB
23.txt AC 26 ms 2420 KB
24.txt AC 26 ms 2420 KB
25.txt WA 25 ms 2420 KB
26.txt AC 26 ms 2420 KB
27.txt AC 26 ms 2420 KB
28.txt AC 23 ms 2420 KB
29.txt AC 25 ms 2420 KB
30.txt AC 26 ms 2420 KB
43.txt AC 1 ms 256 KB
44.txt AC 1 ms 256 KB
45.txt AC 1 ms 256 KB
46.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB
s4.txt AC 1 ms 256 KB