結果

問題 No.1055 牛歩
ユーザー 👑 hitonanodehitonanode
提出日時 2020-05-15 22:53:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,238 bytes
コンパイル時間 2,441 ms
コンパイル使用メモリ 209,668 KB
実行使用メモリ 71,336 KB
最終ジャッジ日時 2023-10-19 16:05:01
合計ジャッジ時間 5,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
70,892 KB
testcase_01 AC 75 ms
71,336 KB
testcase_02 AC 16 ms
4,348 KB
testcase_03 AC 16 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,360 KB
testcase_08 WA -
testcase_09 AC 15 ms
4,348 KB
testcase_10 AC 15 ms
4,348 KB
testcase_11 AC 15 ms
4,348 KB
testcase_12 AC 26 ms
25,384 KB
testcase_13 AC 26 ms
25,384 KB
testcase_14 AC 15 ms
4,348 KB
testcase_15 AC 15 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 14 ms
4,348 KB
testcase_27 AC 16 ms
4,348 KB
testcase_28 AC 14 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 16 ms
4,348 KB
testcase_31 AC 5 ms
4,432 KB
testcase_32 AC 3 ms
4,768 KB
testcase_33 AC 5 ms
4,768 KB
testcase_34 AC 3 ms
4,768 KB
testcase_35 AC 5 ms
4,768 KB
testcase_36 AC 6 ms
4,768 KB
testcase_37 AC 3 ms
4,768 KB
testcase_38 AC 3 ms
4,768 KB
testcase_39 AC 3 ms
4,768 KB
testcase_40 AC 3 ms
4,768 KB
testcase_41 AC 3 ms
4,768 KB
testcase_42 AC 3 ms
4,768 KB
testcase_43 AC 3 ms
4,768 KB
testcase_44 AC 3 ms
4,768 KB
testcase_45 AC 3 ms
4,768 KB
testcase_46 AC 3 ms
4,768 KB
testcase_47 AC 3 ms
4,768 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 2 ms
4,348 KB
testcase_60 AC 3 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 AC 2 ms
4,348 KB
testcase_63 AC 2 ms
4,348 KB
testcase_64 AC 2 ms
4,348 KB
testcase_65 AC 2 ms
4,348 KB
testcase_66 AC 2 ms
4,348 KB
testcase_67 AC 2 ms
4,348 KB
testcase_68 AC 2 ms
4,348 KB
testcase_69 AC 2 ms
4,348 KB
testcase_70 AC 2 ms
4,348 KB
testcase_71 AC 2 ms
4,348 KB
testcase_72 WA -
testcase_73 AC 2 ms
4,348 KB
testcase_74 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void No()
{
    puts("NO");
    exit(0);
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M + 2);
    A[M + 1] = N + 1;
    REP(i, M) cin >> A[i + 1];

    vector<deque<int>> lazy(M + 2);
    auto resolve = [&](auto &&f, int pos, int now) -> void {
        if (A[pos - 1] + 1 == A[pos] and A[pos] + 1 == A[pos + 1])
        {
            No();
        }
        if (A[pos - 1] + 1 == A[pos])
        {
            lazy[pos].pop_front();
            A[pos]++;
            while (lazy[pos + 1].size() > 1 and lazy[pos + 1][1] < now)
            {
                lazy[pos + 1].pop_front();
                lazy[pos + 1].pop_front();
            }
            if (lazy[pos + 1].size()) f(f, pos + 1, lazy[pos + 1].front());
        }
        else if (A[pos] + 1 == A[pos + 1])
        {
            lazy[pos].pop_front();
            A[pos]--;
            while (lazy[pos - 1].size() > 1 and lazy[pos - 1][1] < now)
            {
                lazy[pos - 1].pop_front();
                lazy[pos - 1].pop_front();
            }
            if (lazy[pos - 1].size()) f(f, pos - 1, lazy[pos - 1].front());
        }
    };

    int Q;
    cin >> Q;
    REP(t, Q)
    {
        int b;
        cin >> b;
        lazy[b].emplace_back(t);
        resolve(resolve, b, t);
    }
    puts("YES");
}
0