56402023-08-31 17:24:03TomaSajtTáblajáték 2 (70 pont)cpp17Partially correct 68/703ms3980 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N = 101;
  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;
  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 << '0';
}
SubtaskSumTestVerdictTimeMemory
base68/70
1Accepted0/03ms1812 KiB
2Accepted0/03ms2056 KiB
3Accepted2/23ms2420 KiB
4Accepted3/33ms2496 KiB
5Accepted3/33ms2512 KiB
6Accepted3/32ms2580 KiB
7Accepted3/33ms2712 KiB
8Accepted3/32ms2800 KiB
9Accepted3/33ms2804 KiB
10Accepted3/33ms2944 KiB
11Accepted3/33ms3100 KiB
12Accepted3/33ms3216 KiB
13Accepted3/32ms3220 KiB
14Accepted3/33ms3296 KiB
15Accepted4/43ms3308 KiB
16Accepted4/43ms3440 KiB
17Accepted4/43ms3524 KiB
18Accepted4/43ms3644 KiB
19Accepted4/42ms3648 KiB
20Accepted4/42ms3652 KiB
21Accepted4/42ms3928 KiB
22Accepted4/42ms3980 KiB
23Partially correct1/32ms3980 KiB