56222023-08-09 23:16:27999Táblajáték 2 (70 pont)cpp17Wrong answer 43/703ms4376 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') {
                /*int moves = 0;
                while (ss[ss.size() - 1] == '0') {
                    ss = ss.substr(0, ss.size() - 1);
                    moves++;
                }
                while (moves--) {
                    ss += '2';
                }
            }*/
            if(ss.size()==1){
                ss='0'+ss;
            }
            string c=to_string(ss[ss.size()-2]-'0'-1);
            ss=ss.substr(0,ss.size()-2)+c+"2";
            }
            else {
                string c = to_string(ss[ss.size() - 1] - '0' - 1);
                ss = ss.substr(0, ss.size() - 1) + c;
            }
        } else {
            if(ss.size()==1){
                ss='0'+ss;
            }
            if (ss[ss.size() - 1] == '2') {
                /*int moves = 0;
                while (ss[ss.size() - 1] == '2') {
                    ss = ss.substr(0, ss.size() - 1);
                    moves++;
                }
                while (moves--) {
                    ss += '0';
                }*/
                string c=to_string(ss[ss.size()-2]-'0'+1);
                ss=ss.substr(0,ss.size()-2)+c+"0";
            } else {
                string c = to_string(ss[ss.size() - 1] - '0' + 1);
                ss = ss.substr(0, ss.size() - 1) + c;
            }
        }
    }
    
    cout << s << endl << ss << endl;
}
SubtaskSumTestVerdictTimeMemory
base43/70
1Accepted0/03ms1816 KiB
2Wrong answer0/03ms2052 KiB
3Accepted2/22ms2100 KiB
4Accepted3/33ms2236 KiB
5Accepted3/33ms2444 KiB
6Partially correct1/33ms2684 KiB
7Accepted3/32ms2776 KiB
8Accepted3/33ms2740 KiB
9Partially correct1/32ms2868 KiB
10Partially correct1/32ms2956 KiB
11Accepted3/33ms3080 KiB
12Accepted3/32ms3196 KiB
13Partially correct1/33ms3168 KiB
14Partially correct1/33ms3292 KiB
15Partially correct1/43ms3500 KiB
16Accepted4/42ms3712 KiB
17Accepted4/43ms3800 KiB
18Accepted4/42ms3796 KiB
19Partially correct1/43ms3932 KiB
20Partially correct1/43ms4132 KiB
21Partially correct1/42ms4248 KiB
22Partially correct1/42ms4364 KiB
23Partially correct1/32ms4376 KiB