結果

問題 No.483 マッチ並べ
ユーザー parukiparuki
提出日時 2017-02-10 23:36:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,678 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 181,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 12:26:19
合計ジャッジ時間 3,941 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

vi G[201];
set<pii> fi;
vi r0, c0, r1, c1;
map<pii, int> p2i;
bool ng;
int vis[201], cnt[201];
void f(int u, int p, int s) {
    if(ng)return;
    vis[u] = 1;
    each(v, G[u]) if(v != p) {
        if(vis[v]==1) {
            cnt[v]++;
            if(u == s && cnt[v] > 2)ng = true;
        }
        if(!vis[v]) {
            f(v, u, s);
        }
    }
    vis[u] = 2;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    r0 = c0 = r1 = c1 = vi(N);
    vi X, Y;
    rep(i, N) {
        cin >> r0[i] >> c0[i] >> r1[i] >> c1[i];
        X.pb(r0[i]);
        Y.pb(c0[i]);
        X.pb(r1[i]);
        Y.pb(c1[i]);
    }
    rep(i, 2 * N) {
        auto p = mp(X[i], Y[i]);
        if(!p2i.count(p)) {
            int m = sz(p2i);
            p2i[p] = m;
        }
    }
    rep(i, N) {
        pii p = mp(r0[i], c0[i]), q = mp(r1[i], c1[i]);
        G[p2i[p]].push_back(p2i[q]);
        G[p2i[q]].push_back(p2i[p]);
    }

    int M = sz(p2i);
    for(int i = 0; i < M; ++i) {
        MEM(vis, 0);
        MEM(cnt, 0);
        f(i, -1, i);
    }

    cout << (ng?"NO":"YES") << endl;
}
0