Submission #465780

#TimeUsernameProblemLanguageResultExecution timeMemory
465780MohamedFaresNebiliHandcrafted Gift (IOI20_gift)C++14
0 / 100
1565 ms14848 KiB
#include "gift.h"
#include <bits/stdc++.h>
using namespace std;
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
	bool used=true; string s(n, 'X');
	for(int l=0;l<r&&used;l++) {
		int lo=a[l], hi=b[l], w=x[l];
		if(w==1) {
			char col='X';
			for(int l=lo;l<=hi;l++)
				if(s[l]!='X') col=s[l];
			if(col=='X') col='R';
			for(int l=lo;l<=hi;l++) {
				if(s[l]!='X'&&s[l]!=col) used=false;
				else s[l]=col;
			}
		}
		else if(w==2) {
			int red=0, blue=0;
			for(int l=lo;l<=hi;l++) {
				if(s[l]=='R') red++;
				else if(s[l]=='B') blue++;
			}
			if(red&&blue) continue; 
			char col; bool found=true;
			if(blue==0) col='B';
			else col='R';
			for(int l=lo;l<=hi&&found;l++) {
				if(s[l]=='X') { s[l]=col; found=true; }
			}
			if(!found) used=false;
		}
	}
	for(int l=0;l<n;l++) 
		if(s[l]=='X') s[l]='R';
    if(used) { craft(s); return 1; }
    return 0;
}
#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...