제출 #476572

#제출 시각아이디문제언어결과실행 시간메모리
476572malarHandcrafted Gift (IOI20_gift)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
#include "gift.h"
using namespace std;

int joinBeads(std::vector<int> x,int i, int j, string &s) {
	if(x[i] == 1) {
		if(s[j] == 'B')
		{
		  	return 0;
		} else if(s[j] ==  'R'){
			return 1;
		}
		
		s= s.append("R");
	} 
	else if(x[i] == 2) 
	{
		if(s[j] == 'R') 
		{
		  	return 0;
		} else if(s[j] ==  'B'){
			return 1;
		}
	
		s = s.append("B");
	}	
	return 1;	  			
}

int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
	string s = "";
	int k = 1;

	for(int i=0; i<r; i++) { 
		if(a[i] == 0) { 
			for(int j = a[i]; j <= b[i]; j++) 
			{
	  			k = joinBeads(x,i, j, s);
	  			if(k==0) {
	  				return 0;
				}
	  		} 
		} 
		else 
		{
			for(int j = a[i]+1; j <= b[i]; j++)
			{
	  			s = joinBeads(x, i, j, s);
	  			if(k == 0) {
	  				return 0;
				  }
		  	} 
		}
	}
	
	craft(s);
	
	return 1;
}
#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...