# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053122 | vnm06 | Fountain Parks (IOI21_parks) | C++17 | 95 ms | 39832 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
bool pos[200004];
int used[3][200004];
vector<int> gr[200004];
void dfs(int v)
{
pos[v]=1;
int brs=gr[v].size();
for(int i=0; i<brs; i++)
{
int nv=gr[v][i];
if(!pos[nv]) dfs(nv);
}
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
std::vector<int> u, v, a, b;
for(int i=0; i<x.size(); i++)
{
used[x[i]/2-1][y[i]]=i+1;
}
for(int i=2; i<=200000; i+=2)
{
if(used[0][i] && used[0][i+2])
{
u.push_back(used[0][i]-1);
v.push_back(used[0][i+2]-1);
a.push_back(1);
b.push_back(i+1);
}
if(used[1][i] && used[1][i+2])
{
u.push_back(used[1][i]-1);
v.push_back(used[1][i+2]-1);
a.push_back(5);
b.push_back(i+1);
}
if(used[1][i] && used[0][i])
{
u.push_back(used[1][i]-1);
v.push_back(used[0][i]-1);
a.push_back(3);
b.push_back(i+1);
}
}
for(int i=0; i<u.size(); i++)
{
gr[u[i]].push_back(v[i]);
gr[v[i]].push_back(u[i]);
}
dfs(0);
for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
build(u, v, a, b);
return 1;
}
Compilation message (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |