Submission #796636

#TimeUsernameProblemLanguageResultExecution timeMemory
796636mindiyakPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms212 KiB
#include "paint.h"
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORd(i, a, b) for (ll i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
const int MX = INT_MAX;
const int MN = INT_MIN;

string solve_puzzle(string s, vector<int> c) {
    int n=s.length();
    string ans = s;
    int all = c.size()-1;
    FOR(i,0,c.size())all+=c[i];

    FOR(i,0,n-all+1){
        string temp = s;
        int pos = i;
        bool solved=true;
        FOR(j,0,c.size()){
            FOR(k,0,c[j]){
                if(s[pos+k] == '_'){
                    solved=false;
                }
                temp[pos+k]='X';
            }
            pos+=c[j]+1;
        }
        if(solved==false)continue;
        // cout << temp << endl;
        if(i==0){
            FOR(j,0,n){
                if(temp[j] == 'X'){
                    ans[j]='X';
                }else if(temp[j] == '_' || temp[j]=='.'){
                    ans[j]='_';
                }
            }
        }
        else{
            FOR(j,0,n){
                if(temp[j] == 'X'){
                    if(ans[j] == 'X')ans[j]='X';
                    if(ans[j] == '_')ans[j]='?';
                }else if(temp[j] == '_' or temp[j] == '.'){
                    if(ans[j] == 'X')ans[j]='?';
                    if(ans[j] == '_')ans[j]='_';
                }
            }
        }
    }

    return ans;
}

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:18:39: 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]
   18 | #define FOR(i, a, b) for (ll i = a; i < (b); i++)
      |                                       ^
paint.cpp:43:5: note: in expansion of macro 'FOR'
   43 |     FOR(i,0,c.size())all+=c[i];
      |     ^~~
paint.cpp:18:39: 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]
   18 | #define FOR(i, a, b) for (ll i = a; i < (b); i++)
      |                                       ^
paint.cpp:49:9: note: in expansion of macro 'FOR'
   49 |         FOR(j,0,c.size()){
      |         ^~~
#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...