Submission #840682

# Submission time Handle Problem Language Result Execution time Memory
840682 2023-08-31T15:44:06 Z TheLostCookie Longest Trip (IOI23_longesttrip) C++17
0 / 100
3 ms 208 KB
#include "longesttrip.h"
#include <vector>

std::vector<int> longest_trip(int N, int D) {
	std::vector<int> c0;
	std::vector<int> c1;
	c0.push_back(0);
	for(int i = 1; i < N; i++) {
		(are_connected({0},{i})?c0:c1).push_back(i);
	}
	
	if(are_connected(c0,c1) == false) {
		if(c0.size()>c1.size()) return c0;
		else return c1;
	} else {
		std::vector<int> l(c0), r(c1);
		for(int i = 0; i < 2; i++) {
			while(l.size()>1) {
				std::vector<int> l0,l1;
				for(int j = 0; j < int(l.size()); j++) (j%2?l0:l1).push_back(l[j]);
				if(are_connected(l0,r)) swap(l0,l);
				else swap(l1,l);
			}
			swap(l,r);
		}
		std::vector<int> ans;
		for(auto e: c0) if(e != l[0]) ans.push_back(e);
		ans.push_back(l[0]);
		ans.push_back(r[0]);
		for(auto e: c1) if(e != r[0]) ans.push_back(e);
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 3 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB invalid array
2 Halted 0 ms 0 KB -