This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "gift.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;
#define pb push_back
#define popb pop_back
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int nx[4] = {1,-1,0,0}, ny[4] = {0,0,1,-1};
/////// SOLUTION \\\\\\\
int n, r;
vi a, b, x;
vi p, rnk;
/*void craft(string s)
{
cout << s << '\n';
}*/
int construct(int n, int r, vi a, vi b, vi x)
{
vpi same;
vpi diff;
map<int,int> s;
map<int,int> d;
string res = "";
for(int i= 0; i <n; i ++)
{
s[i]= i;
res += 'R';
}
for(int i= 0; i <r; i ++)
{
if(x[i] == 1)
{
same.pb({a[i],b[i]});
s[a[i]] = max(s[a[i]],b[i]);
}
else
{
diff.pb({a[i],b[i]});
d[a[i]] = max(d[a[i]],b[i]);
}
}
char c= 'R';
for(int i = 0; i < n; i ++)
{
int r = s[i];
for(int u = i; u <= r; u ++)
{
r = max(r,s[u]);
res[u] = c;
}
c = c == 'R'? 'B': 'R';
//cout <<i << ' '<< r;
i = r ;
}
int pref[n+1];
pref[0] = 1;
for(int i = 1; i <n; i ++)
{
pref[i] = pref[i-1] + (res[i] != res[i-1]);
}
for(auto e: diff)
{
if(pref[e.ss] - pref[e.ss] < 1)
return 0;
}
craft(res);
return 1;
}
/*int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int N, R;
cin >> N >> R;
vi A, B, X;
for(int i = 0; i <R;i ++)
{
int ai, bi, xi;
cin >> ai >> bi >> xi;
A.pb(ai); B.pb(bi); X.pb(xi);
}
cout << construct(N,R,A,B,X);
}*/
Compilation message (stderr)
gift.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | /////// SOLUTION \\\\\\\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |