Submission #991859

# Submission time Handle Problem Language Result Execution time Memory
991859 2024-06-03T09:28:22 Z danikoynov Security Gate (JOI18_security_gate) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n;
string s;

void solve()
{
    cin >> n >> s;
    s = "#" + s;
    int cnt = 0;
    for (int i = 1; i <= n; i ++)
    {
        if (s[i] == 'x')
            cnt ++;
    }

    int res = 0;
    for (int mask = 0; mask < (1 << cnt); mask ++)
    {
        int bit = 0;
        string t = s;
        for (int i = 1; i <= n; i ++)
        {
            if (t[i] == 'x')
            {
                //cout << "here " << mask << " " << bit << " " << (mask & (1 << bit)) << endl;
                if ((mask & (1 << bit)) > 0)
                    t[i] = '(';
                else
                    t[i] = ')';
                bit ++;
            }
        }


        bool done = false;
        for (int i = 1; i <= n; i ++)
            for (int j = i; j <= n; j ++)
            {
                int pf = 0;

                bool tf = true;
                for (int d = 1; d <= n; d ++)
                {
                    int c = -1;
                    if (t[d] == '(')
                        c = 1;
                    if (d >= i && d <= j)
                        c *= -1;
                    pf += c;
                    if (pf < 0)
                    {
                        tf = false;
                        break;
                    }
                }
                if (pf != 0)
                    tf = false;
                if (tf)
                {
                    ///cout << i << " : " << j << endl;
                    done = true;
                    break;
                }
            }

        if (done)
            res ++;

        ///cout << t << " " << done << endl;
    }
    cout << res << endl;
}

int main()
{
    speed();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -