# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206005 | oko | Roller Coaster Railroad (IOI16_railroad) | C++14 | 305 ms | 70248 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 "railroad.h"
#include <cstdio>
#include <cassert>
#include<bits/stdc++.h>
using namespace std;
long long n,num;
map<long long,int>mp;
vector<int>gr[200005],v;
void dfs(int x,long long l)
{
num=max(num,l);
for(int i=0;i<gr[x].size();i++)
{
int u=gr[x][i];
dfs(u,l+1);
}
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t)
{
n=s.size();
for(int i=0;i<n;i++)
{
int x=s[i],u=t[i];
v.push_back(x);
v.push_back(u);
}
sort(v.begin(),v.end());
int k=1;
for(int i=0;i<v.size();i++)
{
if(mp[v[i]]==0)mp[v[i]]=k++;
}
for(int i=0;i<n;i++)
{
int x=mp[s[i]],u=mp[t[i]];
gr[x].push_back(u);
}
dfs(1,0);
if(num==n)return 0;
else 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... |