Submission #147695

# Submission time Handle Problem Language Result Execution time Memory
147695 2019-08-30T12:18:59 Z xDWaffle Ljetopica (COI19_ljetopica) C++11
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
#define ff(j, a, b) for(int j=a;j<b;j++)
#define pb push_back;
#define MOD 1000000007

using namespace std;

typedef long long ll;

int n, k;
int a, b, path;


void load_path()
{
    path=1;
    ff(j, 0, n-1)
    {
        char tmp;
        cin >> tmp;
        path=path*2;
        if(tmp=='R')
        {
            path++;
        }
        path=path%MOD;
    }
}

int bin_string_to_int(string s)
{

    int res=0;
    ff(j, 0, n)
    {
        char c=s[j];
        res=res*2;
        if(c=='1')
        {
            res++;
        }
        res=res%MOD;
    }
    return res;
}


int switch_at_depth_q(int q, int pathing)
{
    return ((1 << (n-q) )-1) ^ pathing;
}


int check_pathing(int x)
{
    return (x<=b && x>=a) ? x : 0;
}


int ena_je_budala_neopjevana(int switches, int depth, int pathing)
{
    if(switches==n-depth && switches>0)
    {
        return (ena_je_budala_neopjevana(switches-1, depth+1, switch_at_depth_q(depth, pathing)))%MOD;
    }
    if(depth==1)
    {
        int sol=ena_je_budala_neopjevana(switches, depth+1, pathing);
        sol+=ena_je_budala_neopjevana(switches, depth+1, switch_at_depth_q(depth, pathing));
        if(switches>0)
        {
            sol+=ena_je_budala_neopjevana(switches-1, depth+1, pathing);
            sol+=ena_je_budala_neopjevana(switches-1, depth+1, switch_at_depth_q(depth, pathing));
        }
        return sol%MOD;
    }
    if(switches==0)
    {
        return check_pathing(pathing)%MOD;
    }

    return (ena_je_budala_neopjevana(switches, depth+1, pathing) + ena_je_budala_neopjevana(switches-1, depth+1, switch_at_depth_q(depth, pathing)))%MOD;

}

int main()
{
    cin >> n >> k;
    load_path();
    string tmpa, tmpb;
    cin >> tmpa >> tmpb;
    a=bin_string_to_int(tmpa);
    b=bin_string_to_int(tmpb);
    ///zavrseno ucitavanje!!

    /// XOR <=> ^

    ///cout << (int)ena_je_budala_neopjevana(k, 1, path) << endl;
    cout << (a==b) ? a : (a+b)%MOD;
    return 0;
}

Compilation message

ljetopica.cpp: In function 'int main()':
ljetopica.cpp:100:35: warning: second operand of conditional expression has no effect [-Wunused-value]
     cout << (a==b) ? a : (a+b)%MOD;
                                   ^
ljetopica.cpp:100:31: warning: third operand of conditional expression has no effect [-Wunused-value]
     cout << (a==b) ? a : (a+b)%MOD;
                               ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -