結果

問題 No.360 増加門松列
ユーザー Konton7Konton7
提出日時 2020-02-09 00:57:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,262 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 210,800 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 11:49:13
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:130:9: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized]
  130 |     int p;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


class RangeMinorMaxorSumQuery // 0-index
{
    int const intmax = 2147483647;
    int const intmin = 0;
    vector<PII> sgt;
    int n;
    int k;

public:
    RangeMinorMaxorSumQuery(int n1, int f = -1)
    {
        if (f == -1)
            f = intmax;
        else if (f == 0)
            f = intmin;
        int na = 1;
        int ka = 0;
        while (na < n1)
        {
            na *= 2;
            ka++;
        }
        for (int i = 0; i < 2 * na; i++)
            sgt.push_back(make_pair(f, i));
        n = na;
        k = ka;
    }

    void update_min(int i, int x)
    {
        i += n;
        sgt[i] = make_pair(x, i - n + 1);
        while (i > 1)
        {
            i /= 2;
            sgt[i] = min(sgt[2 * i], sgt[2 * i + 1]);
        }
    }

    PII getmin(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        if (r <= a || b <= l)
            return make_pair(intmax, -1);
        if (a == l && b == r)
            return sgt[k];
        else
            return min(getmin(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2), getmin(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r));
    }

    void printsegtree()
    {
        for (int i = 0; i < 2 * n; i++)
        {
            cout << "(" << sgt[i].first << " " << sgt[i].second << ")"
                 << " ";
        }
        cout << endl;
    }
};

bool kadomatsucheck(int x, int y, int z)
{
    bool ans = false;
    int a[3] = {x, y, z};
    sort(a, a + 3);

    if (a[1] != y && x != y && y != z && z != x && x < z)
        ans = true;
    return ans;
}

bool kadomatsucheck(vector<int> v)
{
    bool ans = true;
    rep(i, 5)
        ans &= kadomatsucheck(v[i], v[i + 1], v[i + 2]);
    return ans;
}

bool kadomatsucheck(vector<int> a, vector<int> b)
{
    bool ans = false;
    vector<int> v;

    do
    {
        do
        {
            v.clear();
            rep(i, 4) v.push_back(a[i]);
            rep(i, 3) v.push_back(b[i]);
            ans |= kadomatsucheck(v);
            if (kadomatsucheck(v))
            {
                for (auto z : v)
                    cout << z;
                cout << endl;
            }
        } while (next_permutation(a.begin(), a.end()));
    } while (next_permutation(b.begin(), b.end()));

    return ans;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    bool ans = false;
    vector<int> a, b;
    int probrem[7];
    int p;
    rep(i, 7)
            cin >> probrem[i];
    sort(probrem, probrem + 7);

    rep(i, pow(2, 7))
    {

        a.clear(), b.clear();

        rep(j, 7)
        {
            if (p % 2)
                a.push_back(probrem[j]);
            else
                b.push_back(probrem[j]);
            p /= 2;
        }
        if (a.size() == 4)
            ans |= kadomatsucheck(a, b);
    }

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