답안 #980160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980160 2024-05-12T00:24:34 Z vjudge1 가장 긴 여행 (IOI23_longesttrip) C++17
40 / 100
10 ms 600 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second

using namespace std;

vector<int> longest_trip(int N, int D){
	if(D==1){
		deque<vector<int>> ans;
		rep(i,0,N){
			ans.pb({i});
		}
		while(ans.size()>2){
			if(are_connected({ans[0].back()},{ans[1].back()})){
				reverse(ans[1].begin(),ans[1].end());
				repa(e,ans[1]) ans[0].pb(e);
				ans.erase(ans.begin()+1);
			}else if(are_connected({ans[0].back()},{ans[2].back()})){
				reverse(ans[2].begin(),ans[2].end());
				repa(e,ans[2]) ans[0].pb(e);
				ans.erase(ans.begin()+2);
			}else{
				reverse(ans[2].begin(),ans[2].end());
				repa(e,ans[2]) ans[1].pb(e);
				ans.erase(ans.begin()+2);
			}
		}
		if(ans[0].size()>ans[1].size()) return ans[0];
		else return ans[1];
	}else{
		deque<int> ans;
		vector<int> aaa;
		ans.pb(0);
		int lf;
		if(are_connected({1},{0})) ans.pb(1), lf=2;
		else ans.pb(2), lf=1;
		if(are_connected({1},{2})) ans.pb(lf);
		else ans.pf(lf);
		rep(i,3,N){
			if(are_connected({i},{ans.back()})) ans.pb(i);
			else ans.pf(i);
		}
		repa(e,ans) aaa.pb(e);
		return aaa;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 5 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 4 ms 452 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 6 ms 344 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 4 ms 452 KB Output is correct
11 Correct 4 ms 456 KB Output is correct
12 Correct 5 ms 448 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 6 ms 344 KB Output is correct
16 Correct 9 ms 344 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 6 ms 596 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 6 ms 444 KB Output is correct
22 Correct 5 ms 600 KB Output is correct
23 Correct 5 ms 456 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 6 ms 500 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
27 Correct 6 ms 344 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 7 ms 344 KB Output is correct
30 Correct 7 ms 344 KB Output is correct
31 Correct 8 ms 344 KB Output is correct
32 Correct 10 ms 344 KB Output is correct
33 Correct 8 ms 344 KB Output is correct
34 Correct 7 ms 344 KB Output is correct
35 Correct 8 ms 344 KB Output is correct
36 Correct 7 ms 600 KB Output is correct
37 Correct 8 ms 600 KB Output is correct
38 Correct 9 ms 452 KB Output is correct
39 Correct 8 ms 448 KB Output is correct
40 Correct 10 ms 344 KB Output is correct
41 Correct 9 ms 344 KB Output is correct
42 Correct 9 ms 344 KB Output is correct
43 Correct 9 ms 600 KB Output is correct
44 Correct 8 ms 600 KB Output is correct
45 Correct 5 ms 344 KB Output is correct
46 Correct 5 ms 344 KB Output is correct
47 Correct 6 ms 344 KB Output is correct
48 Correct 6 ms 344 KB Output is correct
49 Correct 7 ms 344 KB Output is correct
50 Correct 6 ms 344 KB Output is correct
51 Correct 9 ms 344 KB Output is correct
52 Correct 8 ms 344 KB Output is correct
53 Correct 8 ms 344 KB Output is correct
54 Correct 9 ms 344 KB Output is correct
55 Correct 9 ms 344 KB Output is correct
56 Correct 6 ms 600 KB Output is correct
57 Correct 7 ms 344 KB Output is correct
58 Correct 8 ms 600 KB Output is correct
59 Correct 10 ms 448 KB Output is correct
60 Correct 9 ms 600 KB Output is correct
61 Correct 9 ms 440 KB Output is correct
62 Correct 9 ms 432 KB Output is correct
63 Correct 9 ms 600 KB Output is correct
64 Correct 9 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -