結果

問題 No.1021 Children in Classrooms
ユーザー TAISA_TAISA_
提出日時 2020-04-10 21:31:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,644 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 204,180 KB
実行使用メモリ 6,896 KB
最終ジャッジ日時 2023-10-13 23:26:13
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 33 ms
6,640 KB
testcase_10 AC 33 ms
6,580 KB
testcase_11 AC 33 ms
6,644 KB
testcase_12 AC 33 ms
6,636 KB
testcase_13 AC 32 ms
6,728 KB
testcase_14 AC 33 ms
6,612 KB
testcase_15 AC 25 ms
5,960 KB
testcase_16 AC 26 ms
6,000 KB
testcase_17 AC 27 ms
5,952 KB
testcase_18 AC 34 ms
6,896 KB
testcase_19 AC 4 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using V = vector<int>;
using VL = vector<ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    VL a(n);
    deque<ll> q;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        q.pb(a[i]);
    }
    int l = 0, r = n - 1;
    string s;
    cin >> s;
    for (int i = 0; i < m; i++) {
        if (s[i] == 'L') {
            if (q.size() > 1 && l == 0) {
                ll s = q.front();
                q.pop_front();
                s += q.front();
                q.pop_front();
                q.push_front(s);
            }
            r = max(0, r - 1);
            l = max(0, l - 1);
        } else {
            if (q.size() > 1 && r == n - 1) {
                ll s = q.back();
                q.pop_back();
                s += q.back();
                q.pop_back();
                q.push_back(s);
            }
            l = min(n - 1, l + 1);
            r = min(n - 1, r + 1);
        }
    }
    for (int i = 0; i < n; i++) {
        if (l <= i && i <= r) {
            cout << q.front();
            q.pop_front();
        } else {
            cout << 0;
        }
        cout << (i + 1 == n ? '\n' : ' ');
    }
}
0