Submission #957819

#TimeUsernameProblemLanguageResultExecution timeMemory
957819hirayuu_ojHandcrafted Gift (IOI20_gift)C++17
10 / 100
165 ms32768 KiB
#include "gift.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,a,b) for(int i=(a); i<(b); i++) #define all(x) x.begin(),x.end() using ll=long long; char change(char c){ if(c=='R')return 'B'; return 'R'; } int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { string s(n,'-'); vector<pair<int,int>> mono; rep(i,r){ if(x[i]==1){ mono.push_back({a[i],b[i]}); } } sort(all(mono)); int lf=0,ri=-1; char fi='R'; for(auto &[sl,sr]:mono){ if(sl<=ri){ ri=sr; } else{ rep2(i,lf,ri+1){ s[i]=fi; } if((sl-ri)%2==1){ fi=change(fi); } lf=sl; ri=sr; } } rep2(i,lf,ri+1){ s[i]=fi; } char now='R'; rep(i,n){ if(s[i]=='-'){ now=change(now); s[i]=now; } else{ now=s[i]; } s[i]='R'; } vector<ll> cumr(n+1,0); vector<ll> cumb(n+1,0); rep(i,n){ cumr[i+1]=cumr[i]; cumb[i+1]=cumb[i]; if(s[i]=='R'){ cumr[i+1]++; } else{ cumb[i+1]++; } } rep(i,r){ int red=cumr[b[i]+1]-cumr[a[i]]; int blue=cumb[b[i]+1]-cumb[a[i]]; int col=0; if(red!=0)col++; if(blue!=0)col++; if(x[i]!=col){ 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...