結果

問題 No.833 かっこいい電車
ユーザー tomarint2tomarint2
提出日時 2019-05-24 23:13:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,454 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 86,148 KB
実行使用メモリ 12,440 KB
最終ジャッジ日時 2023-09-14 20:55:37
合計ジャッジ時間 7,594 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <unordered_map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll N,Q,q,x;
    cin >> N >> Q;
    vector<bool> connected(N,false);
    vector<ll> A(N,0);

    for1(i,N) {
        cin >> A[i];
    }

    for1(i,Q) {
        cin >> q >> x;
        --x;

        // connect x
        if (q == 1) {
            connected[x] = true;
        }
        // separate x
        else if (q == 2) {
            connected[x] = false;
        }
        // remodel x
        else if (q == 3) {
            A[x] += 1;
        }
        // attractiveness x
        else if (q == 4) {
            ll ans = 0;
            ans = A[x];
            for (ll j = x; j < N && connected[j]; ++j) {
                ans += A[j+1];
            }
            for (ll j = x-1; j >= 0 && connected[j]; --j) {
                ans += A[j];
            }
            cout << ans << endl;
        }
    }
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}
0