# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888753 | ZHIRDILBILDIZ | Longest Trip (IOI23_longesttrip) | C++17 | 6 ms | 600 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<bits/stdc++.h>
#include "longesttrip.h"
#define fi first
#define se second
#define ll long long
using namespace std;
const int N = 256;
//bool gr[N + 1][N + 1];
//bool are_connected(vector<int> a, vector<int> b) {
// for (int i : a)
// for (int j : b)
// if (gr[i][j])
// return 1;
// return 0;
//}
vector<int> longest_trip(int n, int d) {
vector<int> v;
bool us[N + 1][N + 1] = {};
int dp[N + 1] = {};
for (int i = 0; i < n; ++i)
us[i][i] = 1;
if (d == 3) {
for (int i = 0; i < n; ++i)
v.push_back(i);
return v;
}
if (d == 2) {
v.push_back(0);
int abu = 1;
for (int i = 0; i < n - 1, abu < n;) {
vector<int> a = {i}, b = {abu};
if (are_connected(a, b)) {
v.push_back(abu);
i = abu;
++abu;
} else {
if (abu < n - 2) {
v.push_back(abu + 1);
v.push_back(abu);
i = abu;
abu += 2;
} else
break;
}
}
return v;
}
}
//signed main() {
// ios::sync_with_stdio(0);
// cin.tie(0); cout.tie(0);
// int n, d, m;
// cin >> n >> d >> m;
// for (int i = 1; i <= m; ++i) {
// int a, b;
// cin >> a >> b;
// gr[a][b] = gr[b][a] = 1;
// }
// vector<int> ans = longest_trip(n, d);
// cout << ans.size() << '\n';
// for (int i : ans)
// cout << i << ' ';
// cout << "\nare connected\n";
// return 0;
//}
//5 2 8
//0 2
//0 3
//0 4
//1 2
//1 3
//1 4
//2 4
//3 4
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... |