제출 #434179

#제출 시각아이디문제언어결과실행 시간메모리
434179vanicHandcrafted Gift (IOI20_gift)C++14
100 / 100
203 ms18908 KiB
#include "gift.h" #include <iostream> #include <cmath> #include <algorithm> #include <vector> using namespace std; const int maxn=5e5+5; const string s="RB"; int pref[maxn]; int poz[maxn]; int neg[maxn]; string sol; int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) { for(int i=0; i<r; i++){ if(x[i]==1){ poz[a[i]]++; neg[b[i]+1]++; } } int sw=0; bool p=0; for(int i=0; i<n; i++){ sw-=neg[i]; if(!sw){ p^=1; } sw+=poz[i]; pref[i+1]=pref[i]+p; sol.push_back(s[p]); } for(int i=0; i<r; i++){ if(x[i]==2 && (pref[b[i]+1]-pref[a[i]]==0 || pref[b[i]+1]-pref[a[i]]==b[i]-a[i]+1)){ return 0; } } craft(sol); 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...