Submission #427048

#TimeUsernameProblemLanguageResultExecution timeMemory
427048ivan24Paint By Numbers (IOI16_paint)C++14
32 / 100
1 ms204 KiB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;

ll min(ll x, ll y){
    return ((x < y) ? x : y);
}

ll max(ll x, ll y){
    return ((x > y) ? x : y);
}

std::string solve_puzzle(std::string s, std::vector<int> c) {
    string simple_str;
    for (ll i = 0; c.size() > i; i++){
        for (ll j = 0; c[i] > j; j++) simple_str.push_back('X');
        if (i != c.size()-1)simple_str.push_back('_');
    }
    ll n = s.size();
    ll slack = n-simple_str.size();
    if (slack == 0) return simple_str;
    string res;
    res.resize(n);
    for (auto &i: res) i = '?';
    ll ptr = 0;
    for (ll i = 0; c.size() > i; i++){
        ptr += min(c[i],slack);
        for (ll j = 0; max(0,c[i]-slack) > j; j++){
            res[ptr++] = 'X';
        }
        ptr++;
    }
    return res;
}

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:21:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   21 |     for (ll i = 0; c.size() > i; i++){
      |                    ~~~~~~~~~^~~
paint.cpp:23:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if (i != c.size()-1)simple_str.push_back('_');
      |             ~~^~~~~~~~~~~~~
paint.cpp:32:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   32 |     for (ll i = 0; c.size() > i; i++){
      |                    ~~~~~~~~~^~~
#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...