# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
883059 | LeticiaFCS | Longest Trip (IOI23_longesttrip) | C++17 | 12 ms | 1808 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 "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> memo;
int point_query(int a, int b){
if(memo[a][b] != -1) return memo[a][b];
for(int c = 0; c < memo.size(); c++){
if(a == c) continue;
if(b == c) continue;
if(memo[a][c] == 0 && memo[b][c] == 0)
return memo[a][b] = memo[b][a] = 1;
}
return memo[a][b] = memo[b][a] = are_connected({a}, {b});
}
bool merge_paths(vector<int> p1, vector<int> p2, vector<int> &path){
if(p1.size() < p2.size()) swap(p1, p2);
int a = p1[0], b = p1.back();
int c = p2[0], d = p2.back();
vector<int> ends_p1, ends_p2;
if(a == b) ends_p1 = {a};
else ends_p1 = {a,b};
if(c == d) ends_p2 = {c};
else ends_p2 = {c,d};
if(!are_connected(ends_p1, ends_p2)) return false;
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... |