Submission #413056

#TimeUsernameProblemLanguageResultExecution timeMemory
413056nxteruHandcrafted Gift (IOI20_gift)C++14
0 / 100
1 ms276 KiB
#include "gift.h" #include <bits/stdc++.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=0;i<n;i++){ if(ims[i]==0)s[i]=1; if(i>0)s[i]+=s[i-1]; } for(auto i:p[1]){ if(i.first==i.second||s[i.second-1]==s[i.first])return 0; } string ans="R"; for(int i=0;i<n-1;i++){ if(ims[i]==1)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...