56482023-08-31 17:35:26TomaSajtTáblajáték 2 (70 pont)cpp17Runtime error 22/703ms4120 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 < 50) cout << 1 / 0;

  auto it = find_if(d.rbegin(), d.rend(), [](int a) { return a != 0; });
  while (it != d.rend()) {
    cout << *it;
    it++;
  }
}
SubtaskSumTestVerdictTimeMemory
base22/70
1Runtime error0/03ms1788 KiB
2Runtime error0/03ms1968 KiB
3Runtime error0/23ms2184 KiB
4Runtime error0/33ms2432 KiB
5Runtime error0/33ms2448 KiB
6Accepted3/33ms2620 KiB
7Runtime error0/33ms2676 KiB
8Runtime error0/33ms2932 KiB
9Runtime error0/33ms3084 KiB
10Runtime error0/33ms3364 KiB
11Runtime error0/33ms3216 KiB
12Accepted3/33ms3272 KiB
13Runtime error0/33ms3240 KiB
14Runtime error0/33ms3456 KiB
15Runtime error0/43ms3636 KiB
16Runtime error0/43ms3800 KiB
17Runtime error0/43ms3812 KiB
18Runtime error0/43ms3820 KiB
19Accepted4/42ms3848 KiB
20Accepted4/42ms3784 KiB
21Accepted4/43ms4028 KiB
22Accepted4/42ms4032 KiB
23Runtime error0/33ms4120 KiB