Submission #1233668

#TimeUsernameProblemLanguageResultExecution timeMemory
1233668nikulidLongest Trip (IOI23_longesttrip)C++20
5 / 100
3 ms404 KiB
#include "longesttrip.h"


using namespace std;

#define pb push_back

vector<int> longest_trip(int n, int d){
	vector<int> answer;
	if(d==3){
		for(int i=0; i<n; i++){
			answer.pb(i);
		}
	} else if(d==2){
		// surely there still exists a round trip...
		// why is this screaming linked list :(
		vector<int> pr(n, 0);
		for(int i=0; i<n-1; i++){
			if(!are_connected({i}, {i+1})){
				pr[i]=1;
			}
		}
		for(int i=0; i<n; i++){
			if(pr[i]){
				answer.pb(i);
			}
		}
		for(int i=0; i<n; i++){
			if(!pr[i]){
				answer.pb(i);
			}
		}
	}
	return answer;
}
#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...