QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292640#7119. Longest TripInsert_Username_Here0 1ms4092kbC++201.8kb2023-12-28 10:04:432024-04-28 09:12:25

Judging History

你现在查看的是最新测评结果

  • [2024-04-28 09:12:25]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:1ms
  • 内存:4092kb
  • [2023-12-28 10:04:44]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3804kb
  • [2023-12-28 10:04:43]
  • 提交

answer

#include "longesttrip.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
// cope counter = 2254

vector<int> longest_trip(int n, int d) {
	vector<int> l1, l2, l3, a, b, c;
	l1.push_back(0), l2.push_back(1);
	for(int i = 2; i < n; i++) {
		l3.clear();
		l3.push_back(i);
		a.clear(), a.push_back(l1.back());
		b.clear(), b.push_back(l2.back());
		c.clear(), c.push_back(l3.back());
		if(are_connected(a, b)) {
			for(int j = l2.size() - 1; j >= 0; j--) l1.push_back(j);
			l2 = l3;
		} else if(are_connected(a, c)) {
			for(int j = l3.size() - 1; j >= 0; j--) l1.push_back(l3[j]);
		} else {
			for(int j = l3.size() - 1; j >= 0; j--) l2.push_back(l3[j]);
		}
	}
	a.clear(), a.push_back(l1.back());
	b.clear(), b.push_back(l2.back());
	if(are_connected(a, b)) {
		for(int i = l2.size() - 1; i >= 0; i--) l1.push_back(l2[i]);
		return l1;
	}
	int l = 1, r = l2.size(), mid;
	while(l < r) {
		mid = (l + r) / 2;
		l3.clear();
		for(int i = l; i < mid; i++) l3.push_back(l2[i]);
		if(l3.size() > 0 && are_connected(l1, l3)) r = mid;
		else l = mid + 1;
	}
	int bk = r - 1;
	l = 1, r = l1.size();
	b.clear(), b.push_back(l2[bk]);
	while(l < r) {
		mid = (l + r) / 2;
		l3.clear();
		for(int i = l; i < mid; i++) l3.push_back(l1[i]);
		if(l3.size() > 0 && are_connected(b, l3)) r = mid;
		else l = mid + 1;
	}
	a.clear(), a.push_back(l1[mid]);
	if(!are_connected(a, b)) {
		if(l1.size() > l2.size()) return l1;
		return l2;
	}
	l3.clear();
	for(int i = r; i < l1.size(); i++) l3.push_back(l1[i]);
	for(int i = 0; i < r; i++) l3.push_back(l1[i]);
	for(int i = bk; i < l2.size(); i++) l3.push_back(l2[i]);
	for(int i = 0; i < bk; i++) l3.push_back(l2[i]);
	return l3;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

341
3 3
1
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 0 2

result:

wrong answer 

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 4092kb

input:

341
3 2
1
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 0 2

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 1ms
memory: 4092kb

input:

341
3 1
1
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 0 2

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #83:

score: 0
Wrong Answer
time: 1ms
memory: 3808kb

input:

341
3 1
1
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 0 2

result:

wrong answer