64212023-11-28 21:28:39gergomiszoriTáblajátékcpp17Forditási hiba
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl "\n"
#define pll pair<ll,ll>
#define fs first
#define sc second

void solve()
{
    ll k;
    cin >> k;
    ll ans1 = 1, ans2 = 1;
    for(ll i = 0; i < k; i++)
    {
        ll l;
        cin >> l;
        if(l == 0)
        {
            asn2 += (ans2-1)*2;
            ans1++;
        }
        else
        if(l == 1)
        {
            ans2 += (ans2-1)*2 + 1;
            ans1++;
        }
        else
        if(l == 2)
        {
            ans1--;
            ans2 = (ans2/2)+1;
        }
        else
        if(l == 3)
        {
            ans2--;
        }
        else
        if(l == 4)
        {
            ans2++;
        }
        else
    }
    cout << ans1 << endl;
    string s = "";
    while(ans2 > 1)
    {
        if(ans2 % 2 == 0) s += "0";
        else s += "1";
        ans2 /= 2;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'void solve()':
main.cpp:22:13: error: 'asn2' was not declared in this scope; did you mean 'ans2'?
   22 |             asn2 += (ans2-1)*2;
      |             ^~~~
      |             ans2
main.cpp:48:5: error: expected primary-expression before '}' token
   48 |     }
      |     ^
Exited with error status 1