Submission #823353

#TimeUsernameProblemLanguageResultExecution timeMemory
823353tolbiPaint By Numbers (IOI16_paint)C++17
59 / 100
1 ms340 KiB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//ahmet23 orz...
//FatihSultanMehmedHan(ortanca da orz)
//AbdulhamidHan
//YavuzSultanSelimHan
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<pr.first<<" "<<pr.second;}
template<typename T> istream& operator>>(istream& is, vector<T> &arr){for (auto &it : arr) is>>it;return is;}
template<typename T> ostream& operator<<(ostream& os, vector<T> arr){for (auto &it : arr) os<<it<<" ";return os;}
template<typename T, size_t Y> istream& operator>>(istream& is, array<T,Y> &arr){for (auto &it : arr) is>>it;return is;}
template<typename T, size_t Y> ostream& operator<<(ostream& os, array<T,Y> arr){for (auto &it : arr) os<<it<<" ";return os;}
template<typename T> void coutarr(T __arr){for (auto &it : __arr){cout<<it<<" ";}cout<<endl;}
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define endl '\n'
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define vint(x) vector<int> x
#define tol(bi) (1LL<<((int64_t)(bi)))
typedef long long ll;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "paint.h"

#include <cstdlib>

string solve_puzzle(string s, vector<int> c) {
	int n = s.length();
	int m = c.size();
	vector<vector<int>> dp(n, vector<int>(m,-1));
	string rval = s;
	vector<int> ans(n,0);
	function<bool(int,int)> f;
	f = [&](int node, int flag)->bool{
		if (node>=n) return (flag==m);
		if (flag>=m){
			for (int i = node; i < n; i++){
				if (s[i]=='X') return false;
			}
			for (int i = node; i < n; i++){
				ans[i]|=2;
			}
			return true;
		}
		if (dp[node][flag]!=-1) return dp[node][flag];
		dp[node][flag]=0;
		if (s[node]!='X' && f(node+1,flag)==1){
			ans[node]|=2;
			dp[node][flag]=1;
		}
		int l = node, r = node+c[flag]-1;
		if (r>=n) {
			return dp[node][flag];
		}
		bool boolean=true;
		for (int i = l; i <= r; i++){
			if (s[i]=='_') boolean=false;
		}
		if (boolean && f(r+2,flag+1)==1){
			if (r+1>=n || s[r+1]!='X'){
				if (r+1<n) ans[r+1]|=2;
				for (int i = l; i <= r; i++){
					ans[i]|=1;
				}
				dp[node][flag]=1;
			}
		}
		return dp[node][flag];
	};
	f(0,0);
	for (int i = 0; i < n; i++){
		rval[i]='?';
		if (ans[i]==1) rval[i]='X';
		else if (ans[i]==2) rval[i]='_';
	}
	return rval;
}

Compilation message (stderr)

paint.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
#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...