Submission #413061

#TimeUsernameProblemLanguageResultExecution timeMemory
413061nxteruHandcrafted Gift (IOI20_gift)C++14
100 / 100
194 ms29104 KiB
#include "gift.h" using namespace std; int ims[500005],s[500005]; int construct(int n, int r,vector<int> a,vector<int> b,vector<int> x) { vector<pair<int,int>>p[2]; for(int i=0;i<r;i++){ p[x[i]-1].push_back(make_pair(a[i],b[i])); } for(auto i:p[0]){ ims[i.first]++; ims[i.second]--; } for(int i=1;i<n;i++)ims[i]+=ims[i-1]; for(int i=1;i<n;i++){ if(ims[i-1]==0)s[i]=1; if(i>0)s[i]+=s[i-1]; } for(auto i:p[1]){ if(s[i.second]==s[i.first])return 0; } string ans="R"; for(int i=0;i<n-1;i++){ if(ims[i]>0)ans+=ans.back(); else{ if(ans.back()=='R')ans+='B'; else ans+='R'; } } craft(ans); 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...