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 "gift.h"
#include <bits/stdc++.h>
using namespace std;
int construct(int n,int m,vector<int> A,vector<int> B,vector<int> C){
vector<int> D(n); iota(D.begin(),D.end(),0);
for (int i(0);i < m;++i) if (C[i]==1) D[A[i]] = max(D[A[i]],B[i]);
set<int> s; string r,u="RB"; int t=0;
for (int i(0);i < n;++i){
s.emplace(D[i]),r+=u[t];
if (s.find(i)!=s.end()) s.erase(i);
if (s.empty()) t^=1;
}
vector<int> acc(1); int cant = 0; for (char a:r) acc.emplace_back(acc.back()+(a=='B'));
for (int i(0);i < m;++i) if (C[i]==2) if (acc[B[i]+1]-acc[A[i]]==0||acc[B[i]+1]-acc[A[i]]==B[i]-A[i]+1) cant = 1;
if (cant) return 0;
craft(r); return 1;
}
# | 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... |