Submission #11478420


Source Code Expand

#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 10;

typedef struct {
	int x;
	int y;
	int w;
} Loc;

Loc loc [ maxn << 1 ];
int col , row , n;
int x_1 , y_1 , x_2 , y_2 , cnt;
stack < int > ss;
/*
inline int read ( )
{
	int s = 0 , t = 1; char ch = getchar ( );
	while ( ch < '0' || ch > '9' ) { if ( ch == '-' ) t = -1; ch = getchar ( ); }
	while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ( ); }
	return s * t;
}
*/
struct Rude1 {
	bool operator ( ) ( const Loc & s1 , const Loc & s2 ) const {
		return s1.x < s2.x;
	}
};

inline int cha ( int a , int b ) 
{
	if ( a == 0 ) return b;
	else if ( b == col ) return col + a;
	else if ( a == row ) return row + col + col - b;
	else if ( b == 0 ) return col * 2 + row * 2 - a;
	else return -1;
}

int main ( void )
{
//	row = read ( ); col = read ( ); n = read ( );
	scanf ( "%d %d %d" , &row , &col , &n );
	for ( int i = 0 ; i < n ; i++ ) {
//		x_1 = read ( ); y_1 = read ( ); x_2 = read ( ); y_2 = read ( );
		scanf ( "%d %d %d %d" , &x_1 , &y_1 , &x_2 , &y_2 );
		int m = cha ( x_1 , y_1 ); int g = cha ( x_2 , y_2 );
		if ( m == -1 || g == -1 ) {
			continue;
		} 
		if ( m > g ) {
			swap ( m , g );
		}
		loc [ cnt ].w = 1;
		loc [ cnt ].x = m;
		loc [ cnt++ ].y = g;
		loc [ cnt ].w = 2;
		loc [ cnt ].x = g;
		loc [ cnt++ ].y = m;
		sort ( loc , loc + cnt , Rude1 ( ) );
		for ( int i = 0 ; i < cnt ; i++ ) {
			if ( loc [ i ].w == 1 ) {
				ss.push ( loc [ i ].y );
			} else if ( ss.top ( ) == loc [ i ].x ) {
				ss.pop ( );
			} else {
				puts ( "NO" );
				return 0;
			}
		}
	}
	puts ( "YES" );
	return 0;
}


Submission Info

Submission Time
Task E - Connected?
User vjudge3
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1648 Byte
Status TLE
Exec Time 2107 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 21
TLE × 17
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 640 KB
02.txt TLE 2103 ms 512 KB
03.txt TLE 2103 ms 512 KB
04.txt TLE 2103 ms 640 KB
05.txt TLE 2107 ms 512 KB
06.txt TLE 2103 ms 640 KB
07.txt AC 46 ms 256 KB
08.txt TLE 2103 ms 512 KB
09.txt AC 578 ms 384 KB
10.txt TLE 2103 ms 640 KB
11.txt TLE 2103 ms 640 KB
12.txt AC 38 ms 256 KB
13.txt AC 1976 ms 512 KB
14.txt AC 935 ms 512 KB
15.txt AC 32 ms 256 KB
16.txt AC 336 ms 384 KB
17.txt AC 58 ms 256 KB
18.txt AC 48 ms 256 KB
19.txt TLE 2103 ms 512 KB
20.txt AC 1 ms 256 KB
21.txt TLE 2103 ms 512 KB
22.txt AC 306 ms 384 KB
23.txt AC 18 ms 256 KB
24.txt AC 256 ms 384 KB
25.txt TLE 2103 ms 640 KB
26.txt TLE 2103 ms 640 KB
27.txt TLE 2103 ms 640 KB
28.txt TLE 2103 ms 512 KB
29.txt TLE 2103 ms 512 KB
30.txt TLE 2103 ms 512 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