답안 #1063980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063980 2024-08-18T07:22:59 Z AmirAli_H1 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
8 ms 600 KB
// In the name of Allah

#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;

typedef			long long				ll;
typedef			pair<int, int>			pii;
typedef			pair<ll, ll>			pll;

#define			F						first
#define			S						second
#define			endl					'\n'
#define			sep						' '
#define			pb						push_back
#define			Mp						make_pair
#define			all(x)					(x).begin(),(x).end()
#define			len(x)					((ll) (x).size())

const int maxn = 600 + 7;

int n, d;
vector<int> res, resx;
bool mark[maxn];

vector<int> longest_trip(int N, int D) {
	n = N; d = D;
	res.clear(); resx.clear();
	fill(mark, mark + n, 0);
	if (d >= 2) {
		if (are_connected({0}, {1})) {
			res.pb(0); mark[0] = 1;
			res.pb(1); mark[1] = 1;
		}
		else {
			res.pb(0); mark[0] = 1;
			res.pb(2); mark[2] = 1;
		}
		for (int i = 0; i < n; i++) {
			if (mark[i]) continue;
			if (are_connected({i}, {res.back()})) res.pb(i);
			else {
				resx.clear(); swap(res, resx);
				res.pb(i);
				for (int x : resx) res.pb(x);
			}
			mark[i] = 1;
		}
	}
	else {
		
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 7 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 6 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 5 ms 600 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 5 ms 344 KB Output is correct
10 Correct 8 ms 344 KB Output is correct
11 Correct 6 ms 440 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -