結果

問題 No.608 God's Maze
ユーザー PachicobuePachicobue
提出日時 2017-12-13 19:38:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,564 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 201,484 KB
実行使用メモリ 5,276 KB
最終ジャッジ日時 2023-08-21 02:20:16
合計ジャッジ時間 5,219 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,384 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 1 ms
4,384 KB
testcase_29 WA -
testcase_30 AC 4 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 4 ms
4,384 KB
testcase_33 WA -
testcase_34 AC 4 ms
4,384 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 3 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 3 ms
4,384 KB
testcase_41 WA -
testcase_42 AC 4 ms
4,384 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 WA -
testcase_45 AC 4 ms
4,384 KB
testcase_46 AC 2 ms
4,384 KB
testcase_47 AC 1 ms
4,384 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
4,380 KB
testcase_51 WA -
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 1 ms
4,384 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
4,384 KB
testcase_57 WA -
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 2 ms
4,384 KB
testcase_60 WA -
testcase_61 AC 2 ms
4,384 KB
testcase_62 WA -
testcase_63 AC 1 ms
4,384 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    N--;
    string S;
    cin >> S;
    const int size = S.size();
    vector<bool> need(size);
    for (int i = 0; i < size; i++) {
        need[i] = S[i] == '#';
    }
    int left = size;
    int right = 0;
    for (int i = 0; i < size; i++) {
        if (need[i]) {
            left = min(left, i);
            right = max(right, i);
        }
    }
    ll ans = 0;
    for (int i = left; i < N; i++) {
        ans++;
        need[i] = not need[i];
        if (need[i]) {
            right = max(right, i);
        }
    }
    for (int i = left; i < right; i++) {
        ans++;
        need[i + 1] = not need[i + 1];
        if (need[i]) {
            ans += (i == right - 1 ? 1 : 2);
            need[i + 1] = (i == right - 1 ? need[i + 1] : not need[i + 1]);
        }
    }
    cout << ans << endl;
    return 0;
}
0