結果

問題 No.483 マッチ並べ
ユーザー mayoko_mayoko_
提出日時 2015-12-29 12:26:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,959 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 78,812 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-28 10:28:10
合計ジャッジ時間 4,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 111;
pii from[MAXN], to[MAXN];
int cnt[MAXN][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    assert(1 <= N && N <= 100);
    for (int i = 0; i < N; i++) {
        cin >> from[i].first >> from[i].second >> to[i].first >> to[i].second;
        assert(1 <= from[i].first && from[i].first <= 100);
        assert(1 <= from[i].second && from[i].second <= 100);
        assert(1 <= to[i].first && to[i].first <= 100);
        assert(1 <= to[i].second && to[i].second <= 100);
        assert(abs(to[i].first-from[i].first) + abs(to[i].second-from[i].second) == 1);
    }
    for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
        assert(!(from[i] == from[j] && to[i] == to[j]));
    }
    for (int s = 0; s < (1<<N); s++) {
        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < N; i++) {
            if ((s>>i)&1) {
                cnt[from[i].first][from[i].second]++;
            } else {
                cnt[to[i].first][to[i].second]++;
            }
        }
        bool ng = false;
        for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) {
            if (cnt[i][j] > 1) {
                ng = true;
                break;
            }
        }
        if (!ng) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0