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

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

  auto mult3 = [&]() {
    d.insert(d.begin(), 0);
    d.resize(N, 0);
  };
  auto div3 = [&]() {
    d.erase(d.begin());
    d.resize(N, 0);
  };
  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;
  if (k <= 100) cout << 1 / 0;
  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';

  auto it = find_if(d.rbegin(), d.rend(), [](int a) { return a != 0; });
  while (it != d.rend()) {
    cout << *it;
    it++;
  }
  if (row == 0) cout << 1 / 0;
  cout << '\n';
}
SubtaskSumTestVerdictTimeMemory
base0/70
1Runtime error0/03ms1908 KiB
2Runtime error0/03ms2184 KiB
3Runtime error0/23ms2460 KiB
4Runtime error0/33ms2672 KiB
5Runtime error0/33ms2700 KiB
6Runtime error0/33ms2636 KiB
7Runtime error0/33ms2640 KiB
8Runtime error0/33ms2828 KiB
9Runtime error0/33ms3028 KiB
10Runtime error0/33ms3224 KiB
11Runtime error0/33ms3304 KiB
12Runtime error0/33ms3264 KiB
13Runtime error0/33ms3280 KiB
14Runtime error0/33ms3540 KiB
15Runtime error0/43ms3752 KiB
16Runtime error0/43ms3956 KiB
17Runtime error0/43ms3980 KiB
18Runtime error0/43ms3916 KiB
19Runtime error0/43ms4196 KiB
20Runtime error0/43ms4200 KiB
21Runtime error0/43ms4476 KiB
22Runtime error0/43ms4468 KiB
23Runtime error0/33ms4620 KiB