56492023-08-31 17:36:10TomaSajtTáblajáték 2 (70 pont)cpp17Runtime error 0/703ms4724 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N = 150;
  vector<int> d(N);
  int row = 0;

  auto mult3 = [&]() {
    d.insert(d.begin(), 0);
    d.resize(N);
  };
  auto div3 = [&]() {
    d.erase(d.begin());
    d.resize(N);
  };
  auto inc = [&]() {
    int i = 0;
    while (d[i] == 2) {
      d[i] = 0;
      i++;
    }
    d[i]++;
  };
  auto dec = [&]() {
    int i = 0;
    while (d[i] == 0) {
      d[i] = 2;
      i++;
    }
    d[i]--;
  };

  int k;
  cin >> k;
  while (k--) {
    int op;
    cin >> op;
    if (op == 0)
      mult3(), row++;
    else if (op == 1)
      mult3(), inc(), row++;
    else if (op == 2)
      mult3(), inc(), inc(), row++;
    else if (op == 3)
      div3(), row--;
    else if (op == 4)
      dec();
    else if (op == 5)
      inc();
  }

  cout << row << '\n';

  if (row > 5) cout << 1 / 0;

  auto it = find_if(d.rbegin(), d.rend(), [](int a) { return a != 0; });
  while (it != d.rend()) {
    cout << *it;
    it++;
  }
}
SubtaskSumTestVerdictTimeMemory
base0/70
1Accepted0/03ms1964 KiB
2Runtime error0/03ms2280 KiB
3Runtime error0/23ms2304 KiB
4Runtime error0/33ms2860 KiB
5Runtime error0/33ms2836 KiB
6Runtime error0/33ms3108 KiB
7Runtime error0/33ms3316 KiB
8Runtime error0/33ms3348 KiB
9Runtime error0/33ms3548 KiB
10Runtime error0/33ms3916 KiB
11Runtime error0/33ms3988 KiB
12Runtime error0/33ms3960 KiB
13Runtime error0/33ms4040 KiB
14Runtime error0/33ms4244 KiB
15Runtime error0/43ms4500 KiB
16Runtime error0/43ms4584 KiB
17Runtime error0/43ms4724 KiB
18Runtime error0/43ms4648 KiB
19Runtime error0/43ms4648 KiB
20Runtime error0/43ms4540 KiB
21Runtime error0/43ms4540 KiB
22Runtime error0/43ms4540 KiB
23Runtime error0/33ms4540 KiB