| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 891502 | Faisal_Saqib | Split the Attractions (IOI19_split) | C++17 | 74 ms | 22252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int N=2e5+1;
vector<int> ma[N];
int color[N],in[N];
bool vis[N];
set<int> one,two;
void dfs(int x,int a,int b)
{
if(one.size()<a)
{
one.insert(x);
}
else if(two.size()<b)
{
two.insert(x);
}
vis[x]=1;
for(auto y:ma[x])
{
if(!vis[y])
{
dfs(y,a,b);
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
// Swap a,b,c to make a<=b<=c hold and assign new color to each
vector<pair<int,int>> aps;
aps.push_back({a,1});
aps.push_back({b,2});
aps.push_back({c,3});
sort(begin(aps),end(aps));
int colora,colorb,colorc;
a=aps[0].first;
colora=aps[0].second;
b=aps[1].first;
colorb=aps[1].second;
c=aps[2].first;
colorc=aps[2].second;
// Sorting done
// Adding Edges
int m=p.size();
int mx=0;
for(int j=0;j<m;j++)
{
p[j]++;
q[j]++;
ma[p[j]].push_back(q[j]);
ma[q[j]].push_back(p[j]);
in[p[j]]++;
in[q[j]]++;
mx=max(mx,in[p[j]]);
mx=max(mx,in[q[j]]);
}
// Edges added
if(a==1 or mx<=2)
{
bool pos=1;
for(int j=1;j<=n;j++)
{
if(ma[j].size()==1)
{
dfs(j,a,b);
pos=0;
break;
}
}
if(pos)
{
dfs(1,a,b);
}
for(int i=1;i<=n;i++)
{
color[i]=colorc;
}
for(auto i:two)
{
color[i]=colorb;
}
for(auto i:one)
{
color[i]=colora;
}
vector<int> ans;
for(int i=1;i<=n;i++)
{
ans.push_back(color[i]);
}
return ans;
}
else
{
// Greedy algorithm
// Find Set A
// Then Try to Find Set b in every component
}
// exit(-1);
// return {};
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
