結果

問題 No.833 かっこいい電車
ユーザー ritsu2891ritsu2891
提出日時 2019-06-09 14:57:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,314 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 69,240 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 21:06:10
合計ジャッジ時間 8,566 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

void ParseQuery(int QueryId, int x);
void Connect(int x);
void Separate(int x);
void Remodel(int x);
void Attr(int x);

std::vector<int> CoolVals;
std::vector<int> ConnectInfo;

int main() {
    int CarQty, QueryQty;
    scanf("%d%d", &CarQty, &QueryQty);
    for (int i = 0; i < CarQty; i++) {
        int Val;
        scanf("%d", &Val);
        CoolVals.push_back(Val);
        ConnectInfo.push_back(false);
    }
    while (QueryQty-->0) {
        int QueryId, x;
        scanf("%d%d", &QueryId, &x);
        ParseQuery(QueryId, x-1);
    }
    return 0;
}

void ParseQuery(int QueryId, int x) {
    switch (QueryId)
    {
    case 1:
        Connect(x);
        break;
    case 2:
        Separate(x);
        break;
    case 3:
        Remodel(x);
        break;
    case 4:
        Attr(x);
        break;
    default:
        break;
    }
}

void Connect(int x) {
    ConnectInfo[x] = true;
}

void Separate(int x) {
    ConnectInfo[x] = false;
}

void Remodel(int x) {
    CoolVals[x]++;
}

void Attr(int x) {
    int CarPos = x;
    while (CarPos != 0 && ConnectInfo[CarPos-1] == true) {
        CarPos--;
    }
    int Attr = 0;
    do {
        Attr += CoolVals[CarPos];
    } while (ConnectInfo[CarPos++] == true);
    printf("%d\n", Attr);
}
0