이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
int n, k;
const int N = 2e5 + 69;
const int K = 102;
bool dp1[N][K][2];
bool dp2[N][K][2];
int p[N];
bool b1[N], b2[N];
string solve_puzzle(string s, vector<int> c) {
    n = s.length();
    k = c.size();
    s = "0" + s;
    
    for (int i = 1; i <= n; i++){
        p[i] = p[i - 1];
        if (s[i] == '_') p[i]++;
    }
    
    c.push_back(0);
    for (int i = k; i > 0; i--) c[i] = c[i - 1];
    
    dp1[0][0][0] = true;
    for (int i = 1; i <= n; i++){
        if (s[i] != 'X'){
            for (int j = 0; j <= k; j++){
                dp1[i][j][0] |= dp1[i - 1][j][0] | dp1[i - 1][j][1];
            }
        }
        for (int j = 1; j <= k; j++){
            if (i >= c[j] && p[i] == p[i - c[j]]){
                dp1[i][j][1] |= dp1[i - c[j]][j - 1][0];
            }
        }
        
        // cout << i << "\t";
        // for (int j = 0; j <= k; j++){
        //     cout << dp1[i][j][0] << " " << dp1[i][j][1] << "\t";
        // }
        // cout << "\n";
    }
    
    dp2[n + 1][k + 1][0] = true;
    for (int i = n; i >= 1; i--){
        if (s[i] != 'X'){
            for (int j = 1; j <= k + 1; j++){
                dp2[i][j][0] |= dp2[i + 1][j][0] | dp2[i + 1][j][1];
            }
        }
        for (int j = 1; j <= k; j++){
            if (i + c[j] <= n + 1 && p[i - 1] == p[i + c[j] - 1]){
                dp2[i][j][1] |= dp2[i + c[j]][j + 1][0];
            }
        }
    }
    
    string ans = "";
    
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= k; j++){
            if (dp1[i][j][0] && dp2[i][j + 1][0]){
                b1[i] = true;
            }
        }
        
        for (int j = 1; j <= k; j++){
            for (int finish = i; finish <= min(n, i + c[j] - 1); finish++){
                if (dp1[finish][j][1] && dp2[finish + 1][j + 1][0]) b2[i] = true;
            }
        }
        
        if (b1[i] && b2[i]) ans += '?';
        else if (b1[i]) ans += '_';
        else ans += 'X';
    }
    
    return ans;
}
// int main(){
//     string s; cin >> s;
//     int m; cin >> m;
//     vector <int> a(m);
//     for (auto &x : a) cin >> x;
    
//     cout << solve_puzzle(s, a);
//     return 0;
// }
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |