結果

問題 No.2343 (l+r)/2
ユーザー CyanmondCyanmond
提出日時 2023-06-09 21:33:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 4,134 ms
コンパイル使用メモリ 199,828 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 12:57:34
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 321 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 55 ms
4,376 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 14 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 20 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (auto &e : A) std::cin >> e;
    if (A[0] == 1) {
        for (auto &e : A) e = 1 - e;
    }
    if (A[N - 1] == 0) {
        bool isOk = false;
        for (int i = 0; i < N - 1; ++i) {
            if (A[i] == 1 and A[i + 1] == 1) {
                isOk = true;
            }
        }

        int s = 1;
        for (int i = 1; i < N; ++i) {
            if (A[i] != A[i - 1]) {
                ++s;
            }
        }
        if (s >= 9) isOk = true;
        std::cout << (isOk ? "Yes" : "No") << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
}

int main() {
    int T;
    std::cin >> T;
    while (T--) solve();
}
0