56232023-08-09 23:29:57999Táblajáték 2 (70 pont)cpp17Wrong answer 43/703ms4232 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n;
    cin >> n;
    string ss = "0";
    int s = 0;
    
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        
        if (a == 0) {
            s++;
            if(ss!="0"){
            ss += '0';}
        } else if (a == 1) {
            s++;
            if(ss!="0"){
            ss += '1';}
            else{
                ss='1';
            }
        } else if (a == 2) {
            s++;
            if(ss!="0"){
            ss += '2';}
            else{
                ss='2';
            }
        } else if (a == 3) {
            s--;
            ss = ss.substr(0, ss.size() - 1);
        } else if (a == 4) {
            if (ss.size() == 1) {
                ss = '0' + ss;
            }
            if (ss[ss.size() - 1] == '0') {
                ss[ss.size() - 2] = ((ss[ss.size() - 2] - '0' - 1 + 3) % 3) + '0';
                ss[ss.size() - 1] = '2';
            } else {
                ss[ss.size() - 1] = ((ss[ss.size() - 1] - '0' - 1 + 3) % 3) + '0';
            }
        } else {
            if (ss.size() == 1) {
                ss = '0' + ss;
            }
            if (ss[ss.size() - 1] == '2') {
                char c = ((ss[ss.size() - 2] - '0' + 1) % 3) + '0';
                ss[ss.size() - 2] = c;
                ss[ss.size() - 1] = '0';
            } else {
                char c = ((ss[ss.size() - 1] - '0' + 1) % 3) + '0';
                ss[ss.size() - 1] = c;
            }
        }
        }
    cout << s << endl << ss << endl;
}
SubtaskSumTestVerdictTimeMemory
base43/70
1Accepted0/03ms1812 KiB
2Wrong answer0/02ms2056 KiB
3Accepted2/22ms2212 KiB
4Accepted3/32ms2328 KiB
5Accepted3/32ms2524 KiB
6Partially correct1/33ms2776 KiB
7Accepted3/33ms2988 KiB
8Accepted3/32ms3068 KiB
9Partially correct1/32ms3068 KiB
10Partially correct1/32ms3200 KiB
11Accepted3/32ms3280 KiB
12Accepted3/32ms3416 KiB
13Partially correct1/33ms3536 KiB
14Partially correct1/32ms3656 KiB
15Partially correct1/42ms3620 KiB
16Accepted4/42ms3700 KiB
17Accepted4/42ms3700 KiB
18Accepted4/42ms3692 KiB
19Partially correct1/42ms3696 KiB
20Partially correct1/43ms3848 KiB
21Partially correct1/43ms3872 KiB
22Partially correct1/43ms4084 KiB
23Partially correct1/33ms4232 KiB