답안 #840684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840684 2023-08-31T15:45:46 Z TheLostCookie 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
11 ms 284 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(c1.empty() || 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;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 3 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 6 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Incorrect 0 ms 208 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Incorrect 0 ms 208 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Incorrect 0 ms 208 KB Incorrect
7 Halted 0 ms 0 KB -