Submission #5498098


Source Code Expand

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;
struct P2 {
	int x1, x2, y1, y2;
};
bool operator==(const P2& p1, const P2& p2) {
	if (p1.x1 == p2.x1 && p1.y1 == p2.y1 && p1.x2 == p2.x2 && p1.y2 == p2.y2) {
		return true;
	}
	else return false;
}

int R, C, N;
vector<P>v;

bool safe(int x,int y) {
	if (0 < x && x < R) {
		if (0 < y && y < C) {
			return true;
		}
	}
	return false;
}

signed main() {
	cin >> R >> C >> N;
	REP(i, N) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (!safe(x1, y1) && !safe(x2, y2)) {
			int res1;
			if (x1 == 0) {
				res1 = 2 * R + 2 * C - y1;
			}
			else if (y1 == C) {
				res1 = 2 * R + C - x1;
			}
			else {
				res1 = x1 + y1;
			}

			int res2;
			if (x2 == 0) {
				res2 = 2 * R + 2 * C - y2;
			}
			else if (y2 == C) {
				res2 = 2 * R + C - x2;
			}
			else {
				res2 = x2 + y2;
			}
			v.pb(P(res1, i));
			v.pb(P(res2, i));
			//pe(i)pe(res1)print(res2);
		}
	}
	VSORT(v);
	stack<int>stk;
	if (v.size() == 0) {
		print("YES"); return 0;
	}
	stk.push(v[0].second);
	FOR(i,1, v.size()) {
		if (v[i].second == stk.top())stk.pop();
		else {
			stk.push(v[i].second);
		}
	}
	if (stk.empty())print("YES") else print("NO");
}

Submission Info

Submission Time
Task E - Connected?
User Mojumbo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2408 Byte
Status RE
Exec Time 154 ms
Memory 6384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 37
RE × 1
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 AC 147 ms 6384 KB
02.txt AC 137 ms 2420 KB
03.txt AC 143 ms 2420 KB
04.txt AC 136 ms 1400 KB
05.txt AC 141 ms 2420 KB
06.txt AC 138 ms 5744 KB
07.txt AC 141 ms 892 KB
08.txt AC 140 ms 2672 KB
09.txt AC 144 ms 2420 KB
10.txt AC 144 ms 6128 KB
11.txt AC 141 ms 4976 KB
12.txt AC 154 ms 256 KB
13.txt AC 137 ms 892 KB
14.txt AC 129 ms 2420 KB
15.txt AC 137 ms 2420 KB
16.txt AC 140 ms 640 KB
17.txt AC 141 ms 384 KB
18.txt AC 136 ms 256 KB
19.txt AC 137 ms 1400 KB
20.txt AC 142 ms 4720 KB
21.txt AC 141 ms 2420 KB
22.txt AC 140 ms 2420 KB
23.txt AC 145 ms 5616 KB
24.txt AC 144 ms 4848 KB
25.txt AC 145 ms 6384 KB
26.txt AC 145 ms 6256 KB
27.txt AC 143 ms 5872 KB
28.txt AC 135 ms 4848 KB
29.txt AC 143 ms 5872 KB
30.txt AC 142 ms 5104 KB
43.txt RE 96 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