제출 #609390

#제출 시각아이디문제언어결과실행 시간메모리
609390Mohammed_AtalahPaint By Numbers (IOI16_paint)C++17
32 / 100
5 ms312 KiB
#include "paint.h"
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;

std::string solve_puzzle(std::string s, std::vector<int> c) {


    string result = "";
    int total = 0;
    int sz = s.size();
    for (auto &i : c) {
        total += i;
    }
    total += c.size() - 1;
    int e = sz - total;
    int sz2 = c.size();
    if (e == 0) {
        for (int i  = 0; i < sz2; i++) {
            for (int j = 0 ; j < c[i]; j++) {
                result += 'X';
            }
            if (i < sz2 - 1) {
                result += '_';
            }
        }
        return result;
    }

    // cout << e << endl;
    for (int i  = 0; i < sz2; i++) {
        for (int j = 0 ; j < min(c[i], e); j++) {
            result += '?';
        }
        if (c[i] > e) {
            for (int j = 0 ; j < c[i] - e; j++) {
                result += 'X';
            }
        }
        if (i < sz2 - 1)
            result += '?';
    }

    for (int i  = result.size(); i < sz; i++) {
        result += '?';
    }

    return result;
}
#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...