Submission #312448

#TimeUsernameProblemLanguageResultExecution timeMemory
312448talant117408Paint By Numbers (IOI16_paint)C++17
0 / 100
2098 ms275868 KiB
#include "paint.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

string solve_puzzle(string s, vector<int> c) {
    string res = "";
    string a = "", b = "";
    int pos = 0, i, clues = sz(c), j, n = sz(s);
    vector <pii> borders(clues);
    
    for(i = 0; i < n; j++){
        a += '.';
        b += '.';
        res += '?';
    }
    
    for(i = 0; i < clues; i++){
        int flag = -1;
        while(pos < n && s[pos] == '_') pos++;
        for(j = pos; j < pos+c[i]; j++){
            if(s[j] == '_') flag = j;
        }
        if(flag == -1){
            for(j = pos; j < pos+c[i]; j++){
                a[j] = 'X';
            }
            borders[i].first = pos;
            pos += c[i]+1;
        }
        else{
            i--;
            pos = flag+1;
        }
    }
    
    pos = n-1;
    for(i = clues-1; i >= 0; i--){
        int flag = -1;
        while(pos >= 0 && s[pos] == '_') pos--;
        for(j = pos; j > pos-c[i]; j--){
            if(s[j] == '_') flag = j;
        }
        if(flag == -1){
            for(j = pos; j > pos-c[i]; j--){
                b[j] = 'X';
            }
            borders[i].second = pos-c[i]+1;
            pos -= (c[i]+1);
        }
        else{
            i++;
            pos = flag-1;
        }
    }
    
    for(i = 0; i < n; i++){
        if(s[i] == '_'){
            res[i] = '_';
        }
    }
    
    for(i = 0; i < clues; i++){
        int l = borders[i].first, r = borders[i].second;
        for(j = r; j < l+c[i]; j++){
            res[j] = 'X';
        }
    }
    return res;
}
#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...