63942023-11-27 11:06:10MrChipserTáblajátékcpp11Részben helyes 36/503ms3900 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x = 1;
    int y = 1;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a==0)
        {
            y++;
            x=x*2-1;
        }
        if(a==1)
        {
            y++;
            x=x*2;
        }
        if(a==2)
        {
            y--;
            if(x%2==0)
                x=x/2;
            else
                x=(x+1)/2;
        }
        if(a==3)
            x--;
        if(a==4)
            x++;
        //cout << x << " " << y << endl;
    }
    cout << y-1 << endl;
    vector<int>binary;
    x--;
    if(x==0)
        cout << 0;
    else
    {
    while(x!=0)
    {
        binary.insert(binary.begin(),x%2);
        x/=2;
    }
    for(int i = 0; i < binary.size(); i++)
        cout << binary[i];
    }
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base36/50
1Elfogadva0/03ms1684 KiB
2Elfogadva0/03ms1848 KiB
3Elfogadva3/33ms2060 KiB
4Elfogadva3/33ms2268 KiB
5Elfogadva3/32ms2356 KiB
6Részben helyes1/33ms2748 KiB
7Elfogadva3/33ms2796 KiB
8Részben helyes1/33ms2872 KiB
9Elfogadva3/33ms3000 KiB
10Részben helyes1/33ms3088 KiB
11Elfogadva3/33ms3212 KiB
12Részben helyes1/33ms3468 KiB
13Elfogadva4/43ms3456 KiB
14Részben helyes1/43ms3460 KiB
15Elfogadva4/43ms3572 KiB
16Részben helyes1/43ms3816 KiB
17Elfogadva4/43ms3900 KiB