結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー UMRgurashiUMRgurashi
提出日時 2023-08-09 16:01:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 9,305 bytes
コンパイル時間 7,108 ms
コンパイル使用メモリ 311,992 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-05-10 07:28:03
合計ジャッジ時間 7,192 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 31 ms
10,240 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 56 ms
17,272 KB
testcase_06 AC 19 ms
7,296 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 10 ms
6,528 KB
testcase_09 AC 18 ms
8,832 KB
testcase_10 AC 29 ms
10,624 KB
testcase_11 AC 18 ms
7,040 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 10 ms
11,996 KB
testcase_14 AC 16 ms
17,792 KB
testcase_15 AC 11 ms
11,776 KB
testcase_16 AC 5 ms
6,656 KB
testcase_17 AC 13 ms
13,964 KB
testcase_18 AC 10 ms
11,180 KB
testcase_19 AC 14 ms
16,000 KB
testcase_20 AC 12 ms
13,808 KB
testcase_21 WA -
testcase_22 AC 7 ms
8,448 KB
testcase_23 AC 6 ms
7,808 KB
testcase_24 AC 7 ms
8,320 KB
testcase_25 AC 14 ms
15,616 KB
testcase_26 AC 8 ms
8,832 KB
testcase_27 AC 15 ms
16,256 KB
testcase_28 AC 11 ms
12,288 KB
testcase_29 AC 7 ms
8,692 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 14 ms
16,444 KB
testcase_32 AC 7 ms
8,320 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 6 ms
6,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <cstdlib>
#include <atcoder/all>
using namespace atcoder;
#include <chrono>

#define int long long
#define double long double
#define stoi stoll
//#define endl "\n"
using std::abs;

using namespace std;
constexpr double PI = 3.14159265358979323846;
const  int INF = 1LL << 61;
const int dx[8] = { 0,1,0,-1,1,1,-1,-1 };
const int dy[8] = { 1,0,-1,0,1,-1,1,-1 };

#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,n) for(int i=1;i<=n;i++)
#define sREP(i,n) for(int i=1;i*i<=n;++i)
#define krep(i,k,n) for(int i=(k);i<n+k;i++)
#define Krep(i,k,n) for(int i=(k);i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define frep(i,n) for(auto &x:n)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x)
#define RUD(a,b) (((a)+(b)-1)/(b))
#define sum1_n(n) ((n)*(n+1)/2)
#define SUM1n2(n) (n*(2*n+1)*(n+1))/6
#define SUMkn(k,n) (SUM1n(n)-SUM1n(k-1))
#define SZ(x) ((int)(x).size())
#define PB push_back
#define Fi first
#define Se second
#define lower(vec, i) *lower_bound(ALL(vec), i)
#define upper(vec, i) *upper_bound(ALL(vec), i)
#define lower_count(vec, i) (int)(lower_bound(ALL(vec), i) - (vec).begin())
#define acc(vec) accumulate(ALL(vec),0LL)
template<class... T>
constexpr auto min(T... a) {
    return min(initializer_list<common_type_t<T...>>{a...});
}

template<class... T>
constexpr auto max(T... a) {
    return max(initializer_list<common_type_t<T...>>{a...});
}

template<class... T>
void in(T&... a) {
    (cin >> ... >> a);
}


void out() { cout << "\n"; }
template <typename T, class... U, char sep = ' '>
void out(const T& t, const U &...u) {
    cout << t;
    if (sizeof...(u)) cout << sep;
    out(u...);
}

template <typename T>
bool nxp(vector<T>& v) {
    return next_permutation(begin(v), end(v));
}

#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string  __VA_ARGS__; in(__VA_ARGS__)

template <class T>
using v = vector<T>;
template <class T>
using vv = vector<v<T>>;
template <class T>
using vvv = vector<vv<T>>;

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using qint = tuple<int, int, int, int>;

double LOG(int a, int b) {
    return log(b) / log(a);
}
int DISTANCE(pint a, pint b) {
    return (abs(a.first - b.first) * abs(a.first - b.first) + abs(a.second - b.second) * abs(a.second - b.second));
}

inline bool BETWEEN(int x, int min, int max) {
    if (min <= x && x <= max)
        return true;
    else
        return false;
}
inline bool between(int x, int min, int max) {
    if (min < x && x < max) return true;
    else return false;
}
inline bool BETWEEN2(int i, int j, int H, int W) {
    if (BETWEEN(i, 0, H - 1) && BETWEEN(j, 0, W - 1)) return true;
    else return false;
}

template<class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

inline bool bit(int x, int i) {
    return x >> i & 1;
}


void  yn(bool x) {
    if (x) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void  YN(bool x) {
    if (x) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int ipow(int x, int n) {
    int ans = 1;
    while (n > 0) {
        if (n & 1) ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}

template <typename T>
vector<T> compress(vector<T>& X) {
    vector<T> vals = X;
    sort(ALL(vals));
    vals.erase(unique(ALL(vals)), vals.end());
    rep(i, SZ(X))
        X[i] = lower_bound(ALL(vals), X[i]) - vals.begin();
    return vals;
}

v<pint> prime_factorize(int N) {
    v<pint>  res;
    for (int i = 2; i * i <= N; i++) {
        if (N % i != 0) continue;
        int ex = 0;
        while (N % i == 0) {
            ++ex;
            N /= i;
        }
        res.push_back({ i, ex });
    }
    if (N != 1) res.push_back({ N, 1 });
    return res;
}



struct Eratosthenes {
    v<bool> isprime;
    v<int> minfactor;

    Eratosthenes(int N) : isprime(N + 1, true),
        minfactor(N + 1, -1) {
        isprime[0] = false;
        isprime[1] = false;
        minfactor[1] = 1;
        for (int p = 2; p <= N; ++p) {
            if (!isprime[p]) continue;
            minfactor[p] = p;
            for (int q = p * 2; q <= N; q += p) {
                isprime[q] = false;
                if (minfactor[q] == -1) minfactor[q] = p;
            }
        }
    }
    v<pint> factorize(int n) {
        v<pint> res;
        while (n > 1) {
            int p = minfactor[n];
            int exp = 0;
            while (minfactor[n] == p) {
                n /= p;
                ++exp;
            }
            res.emplace_back(p, exp);
        }
        return res;
    }
};

int number_of_divisors(v<pint> p) {
    int ans = 1;
    for (pint x : p) {
        ans *= x.second + 1;
    }
    return ans;
}
int sum_of_divisors(v<pint> p) {
    int ans = 1;
    for (pint x : p) {

    }
    return ans;
}

//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//using mint = modint1000000007;
using mint = modint998244353;
//using mint = static_modint<16637>;

string base_to_k(int n, int k) {
    //n(10)→n(k)
    string ans = "";
    while (n) {
        ans += to_string(n % k);
        n /= k;
    }
    reverse(ALL(ans));
    return ans;
}

template< class T >
struct CumulativeSum2D {
    vector< vector< T > > data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<int >(H + 1, 0)) {}

    void add(int x, int y, T z) {
        ++x, ++y;
        if (x >= data.size() || y >= data[0].size()) return;
        data[x][y] += z;
    }

    void build() {
        for (int i = 1; i < data.size(); i++) {
            for (int j = 1; j < data[i].size(); j++) {
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    T query(int sx, int sy, int gx, int gy) {
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};


const int MAX_ROW = 2010; // to be set appropriately
const int MAX_COL = 2010; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }
};

int GaussJordan(BitMatrix& A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int>& res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);
    //cout << "rank" << " " << SZ(res)-rank << endl;
    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

/*
rep(S, 1 << N) {
        rep(i, N) {
            rep(j, N) {
                if (S != 0 && !(bit(S,i))) continue;
                if (!bit(S,j)) {
                    if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + G[u][v]);
                }
            }
        }
}
*/

vector<int> Z_algorithm(string S) {
    int c = 0, n = S.size();
    vector<int> Z(n, 0);
    for (int i = 1; i < n; i++) {
        int l = i - c;
        if (i + Z[l] < c + Z[c]) {
            Z[i] = Z[l];
        }
        else {
            int j = max(0, c + Z[c] - i);
            while (i + j < n && S[j] == S[i + j])j++;
            Z[i] = j;
            c = i;
        }
    }
    Z[0] = n;
    return Z;
}


void solve() {
    inl(N, K);
    v<int> ch(N);
    inl(M1);
    rep(i, M1) {
        inl(x);
        ch[x] = 1;
    }
    inl(M2);
    rep(i, M2) {
        inl(x);
        ch[x] = 2;
    }
    vv<bool> dp(N+1, v<bool>(2));
    dp[0][0] = true;
    rep(i, N) {
        rep(j, 2) {
            if (dp[i][j]) {
                if (ch[i + 1] == 0)dp[i + 1][j] = true;
                if (ch[i + 1] == 1)dp[i + 1][1] = true;
                if (ch[i + 1] == 2)dp[i + 1][0] = true;
                if (i + K <= N) {
                    if (ch[i + K] == 0)dp[i + K][j] = true;
                    if (ch[i + K] == 1)dp[i + K][1] = true;
                    if (ch[i + K] == 2)dp[i + K][0] = true;
                }
            }
        }
    }
    yn(dp[N][0]);
}

signed main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cout << fixed << setprecision(14);
    //cout << setfill('0') << right << setw(3);
    solve();
}

0