56452023-08-31 17:28:59TomaSajtTáblajáték 2 (70 pont)cpp17Partially correct 68/703ms4624 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;
  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
base68/70
1Accepted0/03ms1812 KiB
2Accepted0/02ms2000 KiB
3Accepted2/22ms2216 KiB
4Accepted3/33ms2428 KiB
5Accepted3/33ms2636 KiB
6Accepted3/33ms3164 KiB
7Accepted3/33ms3116 KiB
8Accepted3/32ms3208 KiB
9Accepted3/32ms3332 KiB
10Accepted3/32ms3400 KiB
11Accepted3/32ms3644 KiB
12Accepted3/33ms3816 KiB
13Accepted3/32ms3772 KiB
14Accepted3/33ms3900 KiB
15Accepted4/43ms4076 KiB
16Accepted4/43ms4196 KiB
17Accepted4/43ms4356 KiB
18Accepted4/43ms4444 KiB
19Accepted4/43ms4552 KiB
20Accepted4/42ms4504 KiB
21Accepted4/42ms4500 KiB
22Accepted4/42ms4624 KiB
23Partially correct1/32ms4620 KiB