Submission #884839

# Submission time Handle Problem Language Result Execution time Memory
884839 2023-12-08T14:32:58 Z djs100201 Longest Trip (IOI23_longesttrip) C++17
15 / 100
7 ms 608 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ = 1e5 + 505, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll gcd(ll x, ll y) {
	if (!y)return x;
	return gcd(y, x % y);
};
vector<int> longest_trip(int N,int D){
	vector<int>ret;
	n=N;
	if(D==3){
		for(int i=0;i<n;i++)ret.push_back(i);
	}
	else if(D==2){
		vector<int>A={0},B={1},C={2};
		deque<ll>T;
		if(are_connected(A,B)){
			T.push_back(0);
			T.push_back(1);
			for(int i=2;i<n;i++){
				A.clear(),B.clear(),C.clear();
				A.push_back(T.front());
				C.push_back(i);
				if(are_connected(A,C))T.push_front(i);
				else T.push_back(i);
			}
		}
		else if(are_connected(B,C)){
			T.push_back(1);
			T.push_back(2);
			for(int i=0;i<n;i++){
				if(i==1 || i==2)continue;
				A.clear(),B.clear(),C.clear();
				A.push_back(T.front());
				C.push_back(i);
				if(are_connected(A,C))T.push_front(i);
				else T.push_back(i);
			}
		}
		else if(are_connected(A,C)){
			T.push_back(0);
			T.push_back(2);
			for(int i=0;i<n;i++){
				if(i==0 || i==2)continue;
				A.clear(),B.clear(),C.clear();
				A.push_back(T.front());
				C.push_back(i);
				if(are_connected(A,C))T.push_front(i);
				else T.push_back(i);
			}
		}
		while(T.size())ret.push_back(T.back()),T.pop_back();
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 5 ms 608 KB Output is correct
5 Correct 5 ms 436 KB Output is correct
6 Correct 7 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 5 ms 436 KB Output is correct
10 Correct 5 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Incorrect
2 Halted 0 ms 0 KB -