結果

問題 No.1400 すごろくで世界旅行
ユーザー yosswi414yosswi414
提出日時 2020-12-09 06:56:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,619 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 206,436 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 02:50:30
合計ジャッジ時間 4,461 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 19 ms
4,380 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 8 ms
4,384 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 50 ms
4,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// head of mylib.h

#include <bits/stdc++.h>

using ll = long long;
using ull = unsigned long long;
using pi = std::pair<ll, ll>;

#define chmin(x, a) ((x) = std::min({(x), (a)})
#define chmax(x, a) ((x) = std::max({(x), (a)})

template <class T>
class V : public std::vector<T> {
    typedef std::vector<T> vector;

  public:
    using vector::begin;
    using vector::end;
    using vector::operator[];
    using vector::back;
    using vector::clear;
    using vector::const_iterator;
    using vector::empty;
    using vector::erase;
    using vector::front;
    using vector::insert;
    using vector::iterator;
    using vector::pop_back;
    using vector::push_back;
    using vector::rbegin;
    using vector::rend;
    using vector::resize;
    using vector::size;
    using vector::vector;

    ll sum() const {
        ll x = 0;
        std::cout << "sum()" << std::endl;
        return x;
    }
    ll max() const {
        ll x = std::numeric_limits<ll>::min();
        std::cout << "max()" << std::endl;
        return x;
    }
    ll min() const {
        ll x = std::numeric_limits<ll>::max();
        std::cout << "min()" << std::endl;
        return x;
    }
};

template <class T>
using VV = V<V<T>>;

template <class T>
std::ostream& operator<<(std::ostream& os, const V<T>& v) {
    for (auto itr = v.begin(); itr != v.end();++itr)
        os << (itr != v.begin() ? " " : "") << *itr;
    os << std::endl;
    return os;
}
template <class T>
std::istream& operator>>(std::istream& is, V<T>& v) {
    for (auto& i : v) is >> i;
    return is;
}

void fin(const char* str){
    std::cout << str << std::endl;
    exit(0);
}

// end of mylib.h

using namespace std;

#define MAX_LEN 1000

int main() {
    int v, d;
    cin >> v >> d;
    using bs = bitset<MAX_LEN>;
    V<bs> E(v);
    for (auto& i : E) {
        cin >> i;
        i <<= (MAX_LEN - v);
    }
    cerr << "input finished" << endl;
    auto cpst = [&E, &v](bs a, bs b) -> bs {
        bs r;
        for (int i = 0; i < v; ++i) {
            if (b[MAX_LEN - i - 1]){
                r |= E[i];
                b.reset(MAX_LEN - i - 1);
                if (b.none()) break;
            }
        }
        return r;
    };
    for (int i = 0; i < v; ++i) {
        bs ei, x(E[i]), y;
        int dd = d;
        ei.set(MAX_LEN - i - 1);
        while (dd > 0) {
            if (dd & 1) {
                ei = cpst(ei, x);
            }
            dd /= 2;
            if (dd < 1) break;
            y = cpst(x, x);
            x = y;
        }
        if (ei.count()<v) return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
}
0