Submission #2113403
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() {
#ifndef ONLINE_JUDGE
freopen("inp.txt", "r", stdin);
#endif
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 |
vjudge5 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2498 Byte |
Status |
TLE |
Exec Time |
2103 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:89:32: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("inp.txt", "r", stdin);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 700 |
Status |
|
|
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 |
TLE |
2103 ms |
256 KB |
02.txt |
TLE |
2103 ms |
256 KB |
03.txt |
TLE |
2103 ms |
256 KB |
04.txt |
TLE |
2103 ms |
256 KB |
05.txt |
TLE |
2103 ms |
256 KB |
06.txt |
TLE |
2103 ms |
256 KB |
07.txt |
TLE |
2103 ms |
256 KB |
08.txt |
TLE |
2103 ms |
256 KB |
09.txt |
TLE |
2103 ms |
256 KB |
10.txt |
TLE |
2103 ms |
256 KB |
11.txt |
TLE |
2103 ms |
256 KB |
12.txt |
TLE |
2103 ms |
256 KB |
13.txt |
TLE |
2103 ms |
256 KB |
14.txt |
TLE |
2103 ms |
256 KB |
15.txt |
TLE |
2103 ms |
256 KB |
16.txt |
TLE |
2103 ms |
256 KB |
17.txt |
TLE |
2103 ms |
256 KB |
18.txt |
TLE |
2103 ms |
256 KB |
19.txt |
TLE |
2103 ms |
256 KB |
20.txt |
TLE |
2103 ms |
256 KB |
21.txt |
TLE |
2103 ms |
256 KB |
22.txt |
TLE |
2103 ms |
256 KB |
23.txt |
TLE |
2103 ms |
256 KB |
24.txt |
TLE |
2103 ms |
256 KB |
25.txt |
TLE |
2103 ms |
256 KB |
26.txt |
TLE |
2103 ms |
256 KB |
27.txt |
TLE |
2103 ms |
256 KB |
28.txt |
TLE |
2103 ms |
256 KB |
29.txt |
TLE |
2103 ms |
256 KB |
30.txt |
TLE |
2103 ms |
256 KB |
43.txt |
TLE |
2103 ms |
256 KB |
44.txt |
TLE |
2103 ms |
256 KB |
45.txt |
TLE |
2103 ms |
256 KB |
46.txt |
TLE |
2103 ms |
256 KB |
s1.txt |
TLE |
2103 ms |
256 KB |
s2.txt |
TLE |
2103 ms |
256 KB |
s3.txt |
TLE |
2103 ms |
256 KB |
s4.txt |
TLE |
2103 ms |
256 KB |