답안 #851673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851673 2023-09-20T11:10:14 Z denniskim 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
6 ms 696 KB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())

ll n;
ll chk[310];

vector<ll> longest_trip(ll N, ll D)
{
	vector<ll> ans;
	set<ll> st;
	n = N;
	
	for(ll i = 0 ; i < n ; i++)
	{
		chk[i] = 0;
		st.insert(i);
	}
	
	if(D == 3)
	{
		for(ll i = 0 ; i < n ; i++)
			ans.push_back(i);
		
		return ans;
	}
	
	if(D == 2)
	{
		ans.push_back(0);
		chk[0] = 1;
		st.erase(0);
		
		while(1)
		{
			ll ff = 0;
			
			for(auto &i : st)
			{
				vector<ll> tmp1, tmp2;
				
				tmp1.push_back(ans.back());
				tmp2.push_back(i);
				
				if(are_connected(tmp1, tmp2))
				{
					ans.push_back(i);
					chk[i] = 1;
					st.erase(i);
					ff = 1;
					break;
				}
			}
			
			if(!ff)
				break;
		}
		
		reverse(ans.begin(), ans.end());
		
		for(auto &i : st)
			ans.push_back(i);
		
		return ans;
	}
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(ll, ll)':
longesttrip.cpp:26:10: warning: control reaches end of non-void function [-Wreturn-type]
   26 |  set<ll> st;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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 4 ms 448 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 696 KB Output is correct
11 Correct 5 ms 444 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -