제출 #466755

#제출 시각아이디문제언어결과실행 시간메모리
466755M4mouHandcrafted Gift (IOI20_gift)C++17
35 / 100
196 ms15616 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; vector<int>parent; void init(int n) { parent.resize(n); for(int l=0;l<n;l++) parent[l]=l; } int findset(int n) { return (parent[n]==n)?n:(parent[n]=findset(parent[n])); } bool sameSet(int a, int b) { return findset(a)==findset(b); } void unionSet(int a, int b) { if(sameSet(a, b)) return; a=findset(a); b=findset(b); parent[a]=b; } int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { init(n+1); for(int i = 0; i < r; i++){ if(x[i] == 2) continue; int j = a[i]; while(findset(j) != findset(b[i])){ unionSet(j,b[i]); j++; } } for(int i=0;i<r;i++){ if(x[i]==1){ continue; } if(findset(a[i])==findset(b[i])){ return 0; } } string s ="R"; for(int i=1;i<n;i++) { if(findset(i) != findset(i-1)) if(s.back() == 'R')s += "B"; else s+= "R"; else s+= s.back(); } 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...