Submission #888753

# Submission time Handle Problem Language Result Execution time Memory
888753 2023-12-18T07:19:09 Z ZHIRDILBILDIZ Longest Trip (IOI23_longesttrip) C++17
5 / 100
6 ms 600 KB
#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

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:30:27: warning: left operand of comma operator has no effect [-Wunused-value]
   30 |         for (int i = 0; i < n - 1, abu < n;) {
      |                         ~~^~~~~~~
longesttrip.cpp:18:10: warning: variable 'us' set but not used [-Wunused-but-set-variable]
   18 |     bool us[N + 1][N + 1] = {};
      |          ^~
longesttrip.cpp:19:9: warning: unused variable 'dp' [-Wunused-variable]
   19 |     int dp[N + 1] = {};
      |         ^~
longesttrip.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 600 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 5 ms 600 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 5 ms 356 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 500 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -