結果

問題 No.8126 Brainfxxk easy
コンテスト
ユーザー Shibaken28
提出日時 2026-04-01 21:59:45
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,864 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,955 ms
コンパイル使用メモリ 325,480 KB
実行使用メモリ 333,324 KB
最終ジャッジ日時 2026-04-01 21:59:57
合計ジャッジ時間 5,452 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <print>
#include <queue>
#include <ranges>
#include <regex>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #include <atcoder/>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(a) a.begin(), a.end()
using namespace std;

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;
}

using ll = long long;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll LINF = numeric_limits<ll>::max() / 2;

void solve() {
    // ここからスタート
    int N;
    cin >> N;
    int ptr = 1;
    string S;
    cin >> S;
    vector<int> A(N + 1, 0);
    bool error = false;
    for (auto c : S) {
        if (c == '+')
            A[ptr]++;
        else if (c == '-')
            A[ptr]--;
        else if (c == '<')
            ptr--;
        else if (c == '>')
            ptr++;
        if (ptr <= 0 || ptr > N) {
            error = true;
            break;
        }
    }
    if (error) {
        println("error");
    } else {
        rep1(i, N) print("{} ", A[i]);
        println();
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
    solve();
    return 0;
}
0