Submission #1060263

# Submission time Handle Problem Language Result Execution time Memory
1060263 2024-08-15T12:25:17 Z Huseyn123 Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "longesttrip.h"
#include <bits/stdc++.h> 
using namespace std; 
vector<int> a,b,c; 
bool f(int x,int l,int r){
    vector<int> d;
    for(int i=l;i<=r;i++){
        d.push_back(b[i]);
    }
    if((int)d.size()==0){
        return false;
    }
    return are_connected({a[x]},d);
}
vector<int> longest_trip(int N, int D){ 
    a.clear(); 
    b.clear(); 
    c.clear();
    vector<int> res;
    if(D==3){ 
        for(int i=0;i<N;i++){
            res.push_back(i);
        }
    }
    else if(D==2){
        set<int> c;
        for(int i=1;i<N;i++){
            c.insert(i);
        }
        res.push_back(0);
        for(int i=0;i<N-1;i++){
            auto it=c.begin();
            if(are_connected({res.back()},{*it})){
                res.push_back(*it);
            }
            else{
                ++it; 
                if(it==c.end()){
                    reverse(res.begin(),res.end());
                    --it; 
                    res.push_back(*it);
                }
                else{
                    res.push_back(*it);
                }
            }
            c.erase(*it);
        }
    }
    else{ 
        a.push_back(0); 
        b.push_back(1);
        for(int i=2;i<N;i++){
            if(are_connected({a.back()},{i})){
                a.push_back(i);
            }
            else if(are_connected({b.back()},{i})){
                b.push_back(i);
            }
            else{
                reverse(b.begin(),b.end()); 
                for(auto x:b){
                    a.push_back(x);
                }
                b.clear();
                b.push_back(i);
            }
        }
        int sz,sz1; 
        sz=(int)a.size(); 
        sz1=(int)b.size();
        for(int i=0;i<sz;i++){
            for(int j=0;j<sz1;j++){
                if(are_connected({a[i]},{b[j]})){
                    if(max(i+1,sz-i)+max(j+1,sz1-j)>(int)c.size()){
                        c.clear();
                        if(i+1>sz-i){
                            for(int z=0;z<=i;z++){
                                c.push_back(a[z]);
                            }
                        }
                        else{
                            for(int z=sz-1;z>=i;z--){
                                c.push_back(a[z]);
                            }
                        }
                        if(j+1>sz1-j){
                            for(int z=j;z>=0;z--){
                                c.push_back(b[z]);
                            }
                        }
                        else{
                            for(int z=j;z<sz1;z++){
                                c.push_back(b[z]);
                            }
                        }
                    }
                }
            }
        }
        if((int)a.size()>(int)b.size()){
            res=a;
        }
        else{
            res=b;
        }
        if((int)c.size()>(int)res.size()){
            res=c;
        }
    }
    return res;
}

Compilation message

closing.cpp:1:10: fatal error: longesttrip.h: No such file or directory
    1 | #include "longesttrip.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.