107862024-04-12 18:53:08TomaSajtTáblajáték 2 (70 pont)cpp17Accepted 70/703ms3372 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N = 101;
  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';

  auto it = find_if(d.rbegin(), d.rend(), [](int a) { return a != 0; });
  if (it == d.rend()) it--;
  while (it != d.rend()) {
    cout << *it;
    it++;
  }
}
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/03ms2084 KiB
2Accepted0/03ms2128 KiB
3Accepted2/23ms2328 KiB
4Accepted3/33ms2568 KiB
5Accepted3/33ms2544 KiB
6Accepted3/33ms2692 KiB
7Accepted3/33ms2892 KiB
8Accepted3/33ms2976 KiB
9Accepted3/33ms3004 KiB
10Accepted3/33ms3076 KiB
11Accepted3/33ms3196 KiB
12Accepted3/32ms3088 KiB
13Accepted3/33ms3096 KiB
14Accepted3/33ms3100 KiB
15Accepted4/43ms3128 KiB
16Accepted4/43ms3108 KiB
17Accepted4/43ms3220 KiB
18Accepted4/43ms3184 KiB
19Accepted4/43ms3188 KiB
20Accepted4/43ms3196 KiB
21Accepted4/43ms3196 KiB
22Accepted4/43ms3324 KiB
23Accepted3/33ms3372 KiB