| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 894843 | Faisal_Saqib | Fountain Parks (IOI21_parks) | C++17 | 1 ms | 512 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 <vector>
#include <map>
#include <queue>
using namespace std;
void build(std::vector<int> u, std::vector<int> v, std::vector<int> a, std::vector<int> b);
int construct_roads(std::vector<int> x, std::vector<int> y)
{
int n=x.size();
vector<int> u,v,a,b;
map<pair<int,int>,int> ind;
for(int i=0;i<n;i++)
ind[{x[i],y[i]}]=1;
map<int,bool> vis;
queue<pair<int,int>> q;
q.push({x[0],y[0]});
while(q.size())
{
auto f=q.front();
q.pop();
if(ind.find({f.first,f.second+2})!=ind.end() and !vis[ind[{f.first,f.second+2}]])
{
vis[ind[{f.first,f.second+2}]]=1;
u.push_back(ind[f]);
v.push_back(ind[{f.first,f.second+2}]);
if(f.first==2)
{
a.push_back(f.first-1);
b.push_back(f.second+1);
}
else// 4
{
a.push_back(f.first+1);
b.push_back(f.second+1);
}
q.push({f.first,f.second+2});
}
if(ind.find({f.first+2,f.second})!=ind.end() and !vis[ind[{f.first+2,f.second}]])
{
vis[ind[{f.first+2,f.second}]]=1;
u.push_back(ind[f]);
v.push_back(ind[{f.first+2,f.second}]);
a.push_back(f.first+1);
b.push_back(f.second+1);
q.push({f.first+2,f.second});
}
}
if(vis.size()!=n)
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... | ||||
