結果

問題 No.483 マッチ並べ
ユーザー ふーらくたるふーらくたる
提出日時 2017-02-11 00:17:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 1,065 ms
コンパイル使用メモリ 72,940 KB
実行使用メモリ 6,772 KB
最終ジャッジ日時 2023-08-28 12:31:49
合計ジャッジ時間 3,349 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,476 KB
testcase_01 WA -
testcase_02 AC 5 ms
6,576 KB
testcase_03 AC 4 ms
6,464 KB
testcase_04 AC 4 ms
6,512 KB
testcase_05 AC 4 ms
6,572 KB
testcase_06 WA -
testcase_07 AC 4 ms
6,504 KB
testcase_08 AC 4 ms
6,480 KB
testcase_09 AC 4 ms
6,484 KB
testcase_10 AC 4 ms
6,484 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
6,512 KB
testcase_14 AC 5 ms
6,600 KB
testcase_15 AC 5 ms
6,524 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
6,696 KB
testcase_19 AC 4 ms
6,568 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
6,496 KB
testcase_26 AC 4 ms
6,632 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 5 ms
6,476 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 4 ms
6,628 KB
testcase_36 AC 4 ms
6,576 KB
testcase_37 AC 4 ms
6,488 KB
testcase_38 AC 4 ms
6,580 KB
testcase_39 AC 4 ms
6,516 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 5 ms
6,540 KB
testcase_44 AC 4 ms
6,572 KB
testcase_45 AC 4 ms
6,508 KB
testcase_46 AC 4 ms
6,548 KB
testcase_47 AC 4 ms
6,504 KB
testcase_48 AC 4 ms
6,580 KB
testcase_49 AC 4 ms
6,604 KB
testcase_50 AC 4 ms
6,764 KB
testcase_51 AC 4 ms
6,528 KB
testcase_52 AC 4 ms
6,708 KB
testcase_53 AC 4 ms
6,640 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <cstring>
#include <vector>
using namespace std;

using P = pair<int, int>;

const int NUM = 114514;

vector<int> graph[NUM];

int color[NUM];

bool dfs(int v, int c, int prev) {
    color[v] = c;

    for (int to : graph[v]) {
        if (to == prev) continue;
        if (color[to] < 0) {
            if (!dfs(to, 1, v)) return false;
        } else if (color[to] == c) {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;

    memset(color, -1, sizeof(color));

    int id = 0;
    map<P, int> dict;
    for (int i = 0; i < n; i++) {
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;

        P p1 = make_pair(r1, c1),
          p2 = make_pair(r2, c2);

        int id1, id2;
        if (dict.find(p1) == dict.end()) {
            dict[p1] = id;
            id++;
        }
        if (dict.find(p2) == dict.end()) {
            dict[p2] = id;
            id++;
        }
        id1 = dict[p1];
        id2 = dict[p2];

        graph[id1].push_back(id2);
        graph[id2].push_back(id1);
    }

    /*
    for (int v = 0; v < id; v++) {
        if (color[v] == -1) {
            if (!dfs(v, 0, -1)) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    */
    cout << "YES" << endl;

    return 0;
}
0