Submission #1284586

#TimeUsernameProblemLanguageResultExecution timeMemory
1284586gustavo_dPaint By Numbers (IOI16_paint)C++20
32 / 100
1 ms348 KiB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()

const int MAXN = 100;

string s; vector<int> rngSzs;
int n, k;

string solve_puzzle(string S, vector<int> C) {
    s = S; rngSzs = C;
    n = sz(s), k = sz(rngSzs);

    string shortest;
    for (int i=0; i<k; i++) {
        for (int j=0; j<rngSzs[i]; j++) shortest += 'X';
        if (i < k-1) shortest += '_';
    }
    if (sz(shortest) == n) {
        return shortest;
    }

    int usedSuf = sz(shortest);
    string ans;
    for (int i=0, ptRng=0, usedPref=-1; i<n; i++) {
        if (ptRng < k and usedPref + 1 + rngSzs[ptRng] <= i) {
            usedPref += 1 + rngSzs[ptRng];
            usedSuf -= (ptRng < k-1) + rngSzs[ptRng];
            ptRng++;
        }
        int suf = n-i-1;
        if (usedSuf > suf) ans += 'X';
        else ans += '?';
    }

    return ans;
}

Compilation message (stderr)

paint.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
paint_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...