Submission #2106113


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int r , c , n ; 
vector<pair<pair<int,int>,int> > arr ; 
bool is(int x , int y) {
    return (x == 0 || y == 0 || y == c || x == r) ;
}
void Insert(int x , int y , int idx) { 
    if(x == 0) arr.pb({{1,y},idx}) ; 
    else if(y == c) arr.pb({{2,x},idx}) ;
    else if(x == r) arr.pb({{3,-y},idx}) ;
    else arr.pb({{4,-x},idx}) ;
}
int32_t main()
{
    fast;
    int idx = 1 ;
    cin >> r >> c >> n ; 
    rep(i,1,n) {
        int x1 , y1 , x2 , y2 ; 
        cin >> x1 >> y1 >> x2 >> y2 ; 
        if(is(x1,y1) && is(x2,y2)) {
            Insert(x1,y1,idx) ;
            Insert(x2,y2,idx) ;
            ++idx ; 
        }
    }
    sort(all(arr)) ;
    stack<int> bla ; 
    for(auto it : arr) {
        if(bla.empty() == false && bla.top() == it.second) bla.pop() ;
        else bla.push(it.second) ;
    }
    if(bla.empty()) cout << "YES\n" ; 
    else cout << "NO\n" ;
    return 0;
}

Submission Info

Submission Time
Task E - Connected?
User SarvagyaAgarwal
Language C++14 (GCC 5.4.1)
Score 700
Code Size 3110 Byte
Status AC
Exec Time 61 ms
Memory 8432 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 38
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 51 ms 7152 KB
02.txt AC 48 ms 4212 KB
03.txt AC 49 ms 4084 KB
04.txt AC 40 ms 1912 KB
05.txt AC 49 ms 3444 KB
06.txt AC 60 ms 8304 KB
07.txt AC 39 ms 1148 KB
08.txt AC 53 ms 3696 KB
09.txt AC 45 ms 4084 KB
10.txt AC 57 ms 7152 KB
11.txt AC 54 ms 7280 KB
12.txt AC 36 ms 256 KB
13.txt AC 39 ms 1148 KB
14.txt AC 45 ms 3444 KB
15.txt AC 47 ms 3444 KB
16.txt AC 38 ms 832 KB
17.txt AC 38 ms 384 KB
18.txt AC 37 ms 384 KB
19.txt AC 43 ms 1912 KB
20.txt AC 60 ms 7408 KB
21.txt AC 45 ms 4468 KB
22.txt AC 46 ms 4724 KB
23.txt AC 59 ms 8432 KB
24.txt AC 59 ms 7664 KB
25.txt AC 60 ms 6512 KB
26.txt AC 60 ms 7664 KB
27.txt AC 60 ms 6896 KB
28.txt AC 59 ms 7408 KB
29.txt AC 60 ms 7920 KB
30.txt AC 61 ms 7536 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