Submission #707722

#TimeUsernameProblemLanguageResultExecution timeMemory
707722AdamGSHandcrafted Gift (IOI20_gift)C++17
100 / 100
161 ms24952 KiB
#include "gift.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=5e5+7; int F[LIM], T[LIM]; int fnd(int x) { if(F[x]==x) return x; return F[x]=fnd(F[x]); } void uni(int a, int b) { F[fnd(b)]=fnd(a); } int construct(int n, int r, vector<int>a, vector<int>b, vector<int>x) { rep(i, n) T[i]=F[i]=i; rep(i, r) if(x[i]==1) T[a[i]]=max(T[a[i]], b[i]); rep(i, n) { if(i) T[i]=max(T[i], T[i-1]); if(T[i]>i) uni(i, i+1); } rep(i, r) if(x[i]==2 && fnd(a[i])==fnd(b[i])) return 0; int akt=0; string ans=""; rep(i, n) { if(!akt) ans+="R"; else ans+="B"; if(fnd(i)!=fnd(i+1)) akt^=1; } 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...