Submission #3810849


Source Code Expand

#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int R, C, N; cin >> R >> C >> N;
    int x1, y1, x2, y2;
    vector<Pii> p1(0), p2(0), p3(0), p4(0);

    REP(i, N){
        cin >> x1 >> y1 >> x2 >> y2;
        if(!(x1 == 0 || x1 == R || y1 == 0 || y1 == C)) continue;
        if(!(x2 == 0 || x2 == R || y2 == 0 || y2 == C)) continue;
        if(x1 == 0) p1.push_back(Pii(y1, i));
        else if(x1 == R) p3.push_back(Pii(y1, i));
        else if(y1 == 0) p4.push_back(Pii(x1, i));
        else if(y1 == C) p2.push_back(Pii(x1, i));
        if(x2 == 0) p1.push_back(Pii(y2, i));
        else if(x2 == R) p3.push_back(Pii(y2, i));
        else if(y2 == 0) p4.push_back(Pii(x2, i));
        else if(y2 == C) p2.push_back(Pii(x2, i));
    }
    vec v(0);
    SORT(p1);
    SORT(p2);
    SORT(p3); REVERSE(p3);
    SORT(p4); REVERSE(p4);
    REP(i, p1.size()) v.push_back(p1[i].second);
    REP(i, p2.size()) v.push_back(p2[i].second);
    REP(i, p3.size()) v.push_back(p3[i].second);
    REP(i, p4.size()) v.push_back(p4[i].second);

    if(v.size() == 0){
        cout << "YES";
        return 0;
    }

    //REP(i, v.size()) cout << v[i] << endl;
    bool f = false;
    int n = v.size();
    REP(i, n){
        if(v[i] == v[(i + 1) % n]){
            f = true;
            REP(j, n) if(v[(i - j + n) % n] != v[(i + 1 + j) % n]) f = false;
            break;
        }
    }
    ANS(f);
    
    return 0;
}

Submission Info

Submission Time
Task E - Connected?
User sumitacchan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2387 Byte
Status WA
Exec Time 151 ms
Memory 7216 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 26
WA × 12
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 WA 136 ms 5352 KB
02.txt WA 142 ms 3940 KB
03.txt WA 145 ms 3572 KB
04.txt WA 146 ms 1720 KB
05.txt WA 145 ms 3180 KB
06.txt WA 144 ms 7008 KB
07.txt AC 145 ms 1024 KB
08.txt AC 145 ms 4436 KB
09.txt AC 144 ms 3060 KB
10.txt AC 149 ms 6360 KB
11.txt AC 145 ms 5556 KB
12.txt WA 137 ms 256 KB
13.txt WA 139 ms 1052 KB
14.txt AC 132 ms 2708 KB
15.txt AC 140 ms 2728 KB
16.txt WA 142 ms 640 KB
17.txt WA 144 ms 384 KB
18.txt WA 138 ms 384 KB
19.txt AC 140 ms 1600 KB
20.txt AC 149 ms 6860 KB
21.txt AC 144 ms 2568 KB
22.txt AC 143 ms 2968 KB
23.txt AC 150 ms 6312 KB
24.txt AC 150 ms 5528 KB
25.txt WA 149 ms 5548 KB
26.txt AC 151 ms 7216 KB
27.txt AC 148 ms 5608 KB
28.txt AC 141 ms 5592 KB
29.txt AC 148 ms 5508 KB
30.txt AC 149 ms 5508 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 4 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