답안 #815736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815736 2023-08-08T20:17:32 Z denniskim Handcrafted Gift (IOI20_gift) C++17
15 / 100
107 ms 17000 KB
#include "gift.h"
#include <bits/stdc++.h>

using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())

ll arr[5000010];
ll num[5000010];
string ans;
vector<pll> vec;

int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x)
{
	for(ll i = 0 ; i < n ; i++)
	{
		if(x[i] == 1)
			vec.push_back({b[i], a[i]});
	}
	
	ll cc = 1, cc2 = 1;
	ll gapa = 0;
	
	if(!vec.empty())
	{
		sort(vec.begin(), vec.end());
		
		ll S = vec[0].se;
		ll E = vec[0].fi;
		
		for(auto &i : vec)
		{
			if(!gapa)
			{
				gapa = 1;
				continue;
			}
			
			if(E < i.se)
			{
				for(ll j = S ; j <= E ; j++)
					arr[j] = cc;
				
				cc++;
				S = i.se, E = i.fi;
			}
			
			else
				E = max(E, i.fi);
		}
		
		for(ll j = S ; j <= E ; j++)
			arr[j] = cc;
		
		cc++;
	}
	
	for(ll i = 0 ; i < n ; i++)
	{
		if(!arr[i])
			arr[i] = cc++;
	}
	
	for(ll i = 0 ; i < n ; i++)
	{
		if(!num[arr[i]])
			num[arr[i]] = cc2++;
	}
	
	for(ll i = 0 ; i < n ; i++)
	{
		if(x[i] == 2)
		{
			if(num[arr[b[i]]] - num[arr[a[i]]] == 0)
				return 0;
		}
	}
	
	char now = 'R';
	
	ans.push_back('R');
	
	for(ll i = 1 ; i < n ; i++)
	{
		if(arr[i] != arr[i - 1])
			now = 'B' + 'R' - now;
		
		ans.push_back(now);
	}
	
	craft(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Possible does not match answer file
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 107 ms 16996 KB Output is correct
5 Correct 104 ms 17000 KB Output is correct
6 Correct 99 ms 15916 KB Output is correct
7 Correct 105 ms 15904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Requirement 3 not satisfied
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Requirement 5 not satisfied
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Possible does not match answer file
2 Halted 0 ms 0 KB -