Submission #1059899

#TimeUsernameProblemLanguageResultExecution timeMemory
1059899dozerLongest Trip (IOI23_longesttrip)C++17
30 / 100
235 ms604 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; #define sp " " #define endl "\n" #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define pb push_back #define pii pair<int, int> #define st first #define nd second #define LL node * 2 #define RR node * 2 + 1 #define ll long long const int modulo = 1e9 + 7; const ll INF = 2e18 + 7; vector<int> longest_trip(int N, int D) { vector<int> ans; set<int> undone; for (int i = 1; i < N; i++) undone.insert(i); ans.pb(0); while(!undone.empty()){ vector<int> tmp(undone.begin(), undone.end()); vector<int> a = {ans.back()}; int go = -1; for (auto j : tmp){ vector<int> b = {j}; if (are_connected(a, b)){ go = j; break; } } if (go == -1){ int sz = ans.size(); if (sz * 2 >= N){ return ans; } return tmp; } else{ ans.pb(go); undone.erase(go); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...