Submission #1076404

# Submission time Handle Problem Language Result Execution time Memory
1076404 2024-08-26T13:38:24 Z MarwenElarbi Longest Trip (IOI23_longesttrip) C++17
5 / 100
897 ms 932 KB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
const int nax = 2e5+5;
const int MOD = 1e9+7;
vector<int> adj[256];
std::vector<int> longest_trip(int N, int D)
{
    for (int i = 0; i < N; ++i)
    {
        adj[i].clear();
    }
    if(N==3){
        if(are_connected({0},{1})&&are_connected({1},{2})) return {0,1,2};
        else return {0,2,1};
    }
    set<int> st;
    for (int i = 0; i < N; ++i)
    {
        st.insert(i);
        for (int j = i+1; j < N; ++j)
        {
            if(!are_connected({i},{j})){
                cout <<i<<" "<<j<<endl;
                adj[i].pb(j);
                adj[j].pb(i);
            }
        }
    }
    int cur=0;
    st.erase(0);
    vector<int> ans;
    ans.pb(0);
    while(!st.empty()){
        if(adj[cur].size()==1){
            for(auto u:st) {
                if(u==adj[cur][0]) continue;
                cur=u;
                ans.pb(u);
                st.erase(u);
                break;
            }
        }else{
            cur=*st.begin();
            ans.pb(*st.begin());
            st.erase(*st.begin());
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Secret mismatch (possible tampering with the output).
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 141 ms 344 KB Output is correct
4 Correct 448 ms 592 KB Output is correct
5 Correct 817 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 20 ms 344 KB Output is correct
3 Correct 145 ms 344 KB Output is correct
4 Correct 379 ms 344 KB Output is correct
5 Correct 897 ms 432 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 8 ms 344 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Correct 126 ms 344 KB Output is correct
4 Correct 363 ms 432 KB Output is correct
5 Correct 743 ms 436 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 5 ms 344 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Partially correct 152 ms 440 KB Output is partially correct
4 Partially correct 425 ms 420 KB Output is partially correct
5 Partially correct 884 ms 428 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -