| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357880 | maya_s | Longest Trip (IOI23_longesttrip) | C++20 | 4 ms | 412 KiB |
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
vector<int> longest_trip(int n, int d)
{
vector<ll> ans;
stack<ll> s[2]; s[0].push(0);
for(ll i = 1; i < n; i++){
if(s[1].empty()){
if(are_connected({s[0].top()}, {i})) s[0].push(i);
else s[1].push(i);
}
else{
if(are_connected({s[0].top()}, {i})) {
s[0].push(i);
if(are_connected({s[1].top()}, {i})) while(s[1].size()) s[0].push(s[1].top()), s[1].pop();
}
else s[1].push(i);
}
}
if(s[0].size() < s[1].size()) swap(s[0], s[1]);
while(s[0].size()) ans.push_back(s[0].top()), s[0].pop();
return ans;
}
| # | 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... | ||||
