Submission #847318

# Submission time Handle Problem Language Result Execution time Memory
847318 2023-09-09T13:26:40 Z hariaakas646 Paint By Numbers (IOI16_paint) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "paint.h"

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

std::string solve_puzzle(std::string st, std::vector<int> c) {
    int n= st.size();
    int k = c.size();

    vi vec(n);
    frange(i, n) {
        if(st[i] == 'X') vec[i] = 1;
        else if(st[i] == '.') vec[i] = -1;
    }
    string out = "";
    frange(i, n) {
        if(vec[i] != -1) {
            if(vec[i]) out += 'X';
            else out += '_';
        }
        vector<vvi> dp(n, vvi(k+1, vi(n+1)));
        vec[i] = 1;
        forr(j, 0, n)
            dp[j][0][0] = true;
        dp[0][1][1] = true;

        forr(j, 1, n) {
            forr(l, 1, k+1) {
                dp[j][l][0] = dp[j-1][l][0] || dp[j-1][l][vec[j]];
                dp[j][l][1] = dp[j-1][l-1][0];
                forr(e, 2, vec[j]+1) {
                    dp[j][l][e] = dp[j-1][l][e-1];
                }
            }
        }
        bool black = dp[n][k][n];
        dp = vector<vvi>(n, vvi(k+1, vi(n+1)));
        vec[i] = 0;
        forr(j, 0, n)
            dp[j][0][0] = true;
        dp[0][1][1] = true;

        forr(j, 1, n) {
            forr(l, 1, k+1) {
                dp[j][l][0] = dp[j-1][l][0] || dp[j-1][l][vec[j]];
                dp[j][l][1] = dp[j-1][l-1][0];
                forr(e, 2, vec[j]+1) {
                    dp[j][l][e] = dp[j-1][l][e-1];
                }
            }
        }
        bool white = dp[n][k][n];
        if(black && white) {
            out += '?';
        }
        else if(black) out += 'B';
        else out += 'W';
    }
    return out;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -