Submission #856902

# Submission time Handle Problem Language Result Execution time Memory
856902 2023-10-04T19:36:46 Z IS_Rushdi Longest Trip (IOI23_longesttrip) C++17
5 / 100
44 ms 464 KB
#include<bits/stdc++.h>
using namespace std;
#include "longesttrip.h"

vector<int> longest_trip(int n, int k)
{
    vector<int>ans;
    if(k == 3) for(int i = 0; i < n; i++) ans.push_back(i);
    else if(k == 2){
        int v = 0; 
        ans.push_back(0);
        set<int>st;
        for(int i = 1; i < n; i++) st.insert(i);

        for(int i = 1; i < n; i++){
            set<int>st2 = st;
            vector<int>wow;wow.push_back(v);
            while(st2.size() > 1){
                int m = st2.size()/2;
                vector<int>arr;
                auto it = st2.begin();
                for(int z = 0; z < m; z++){
                    arr.push_back(*it);
                    it++;
                }
                bool ok = are_connected(wow,arr);
                if(ok){
                    while(it != st2.end()){
                        auto prev = it;
                        it++;
                        st2.erase(prev);
                    }
                }else{
                    for(int x : arr) st2.erase(x);
                }
            }
            auto it = st2.begin();
            ans.push_back(*it);
            st.erase(*it);
            v = (*it);
        }
        
    }

    return {ans};
}
// int main(){

// }

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 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 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 24 ms 344 KB Output is correct
4 Correct 39 ms 452 KB Output is correct
5 Correct 44 ms 464 KB Output is correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -