Submission #11479987
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int maxn = 1e5 + 10; int row , col , n ,top , f [ maxn ] , x_1 , y_1 , x_2 , y_2; bool vis [ maxn ]; vector < pair < int , int > > v [ 4 ]; inline bool check ( int a , int b ) { if ( a == 0 || a == row || b == 0 || b == col ) { return true; } return false; } 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; } void get_in ( int Row , int Col , int flag ) { if ( !Row ) { v [ 0 ].emplace_back ( make_pair ( Col , flag ) ); } else if ( col == Col ) { v [ 1 ].emplace_back ( make_pair ( Row , flag ) ); } else if ( row == Row ) { v [ 2 ].emplace_back ( make_pair ( col - Col , flag ) ); } else { v [ 3 ].emplace_back ( make_pair ( row - Row , flag ) ); } } int main ( void ) { row = read ( ); col = read ( ); n = read ( ); for ( int i = 1 ; i <= n ; i++ ) { x_1 = read ( ); y_1 = read ( ); x_2 = read ( ); y_2 = read ( ); if ( check ( x_1 , y_1 ) && check ( x_2 , y_2 ) ) { get_in ( x_1 , y_1 , i ); get_in ( x_2 , y_2 , i ); } } for ( int i = 0 ; i < 4 ; i++ ) { sort ( v [ i ].begin ( ) , v [ i ].end ( ) ); for ( vector < pair < int , int > >::iterator x = v [ i ].begin ( ) ; x != v [ i ].end ( ) ; x++ ) { int flag = x->second; if ( !vis [ flag ] ) { f [ ++top ] = flag; vis [ flag ] = 1; } else if ( !top || f [ top ] != flag ) { puts ( "NO" ); return 0; } else { --top; } } } puts ( "YES" ); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Connected? |
User | vjudge1 |
Language | C++14 (Clang 3.8.0) |
Score | 700 |
Code Size | 1672 Byte |
Status | AC |
Exec Time | 42 ms |
Memory | 2520 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | AC | 35 ms | 1724 KB |
02.txt | AC | 34 ms | 1492 KB |
03.txt | AC | 37 ms | 1648 KB |
04.txt | AC | 29 ms | 832 KB |
05.txt | AC | 35 ms | 1404 KB |
06.txt | AC | 40 ms | 2412 KB |
07.txt | AC | 29 ms | 640 KB |
08.txt | AC | 35 ms | 1752 KB |
09.txt | AC | 29 ms | 1016 KB |
10.txt | AC | 39 ms | 2036 KB |
11.txt | AC | 36 ms | 1732 KB |
12.txt | AC | 27 ms | 384 KB |
13.txt | AC | 29 ms | 748 KB |
14.txt | AC | 27 ms | 1236 KB |
15.txt | AC | 32 ms | 1192 KB |
16.txt | AC | 29 ms | 512 KB |
17.txt | AC | 29 ms | 384 KB |
18.txt | AC | 27 ms | 384 KB |
19.txt | AC | 30 ms | 1024 KB |
20.txt | AC | 39 ms | 2516 KB |
21.txt | AC | 32 ms | 1100 KB |
22.txt | AC | 33 ms | 1236 KB |
23.txt | AC | 32 ms | 2184 KB |
24.txt | AC | 34 ms | 2460 KB |
25.txt | AC | 41 ms | 2228 KB |
26.txt | AC | 35 ms | 2520 KB |
27.txt | AC | 41 ms | 2228 KB |
28.txt | AC | 32 ms | 2460 KB |
29.txt | AC | 41 ms | 2240 KB |
30.txt | AC | 42 ms | 2240 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 |