#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const int N = 1000 * 1000 + 7;
bool SQ(int a, int b)
{
vector<int> v1 = {a}, v2 = {b};
return are_connected(v1, v2);
}
void J(vector<int> &a, vector<int> &b)
{
for(int i = 0; i < (int)b.size(); ++i)
a.pb(b[i]);
b.clear();
}
vector<int> longest_trip(int _N, int _X_D)
{
int n = _N;
vector<int> l1, l2;
l1.pb(0);
if(n == 1) return l1;
for(int i = 2; i < n; ++i)
{
if(SQ(i, l1.back()))
{
l1.pb(i);
continue;
}
if((int)l2.size() == 0 || SQ(i, l2.back()))
{
l2.pb(i);
continue;
}
reverse(l2.begin(), l2.end());
J(l1, l2);
l2.pb(i);
}
if(l1.size() < l2.size())
swap(l1, l2);
return l1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
336 KB |
Output is correct |
2 |
Correct |
9 ms |
336 KB |
Output is correct |
3 |
Correct |
6 ms |
336 KB |
Output is correct |
4 |
Correct |
9 ms |
336 KB |
Output is correct |
5 |
Correct |
9 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |