QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217467#7119. Longest Triphocky#0 1ms3936kbC++141.2kb2023-10-16 21:27:092024-04-28 08:58:41

Judging History

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

  • [2024-04-28 08:58:41]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:1ms
  • 内存:3936kb
  • [2023-10-16 21:27:09]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3956kb
  • [2023-10-16 21:27:09]
  • 提交

answer

#include "longesttrip.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i = a;i < b;i++)
#define trav(nx, v) for(auto &nx : v)
#define all(a) begin(a), end(a)
#define sz(v) (int) v.size()

vector <int> edge[260];
bool vis[260];
int len = 0;
int path[260];
int cnt = 0;
vector <int> ans;

mt19937 rng(time(0));

void dfs(LL pos){
	vis[pos] = 1;
	
	path[cnt] = pos;
	cnt++;
	trav(nx, edge[pos]){
		if(vis[nx]) continue;
		dfs(nx);
	}
	if(cnt > sz(ans)){
		ans.resize(cnt);
		rep(i,0,cnt) ans[i] = path[i];
	}
	cnt--;
}

std::vector<int> longest_trip(int N, int D)
{
	vector <int> perm(N);
	iota(all(perm), 0);
	shuffle(all(perm), rng);
	rep(i,0,N - 2){
		int a = perm[i];
		int b = perm[i + 1];
		int c = perm[i + 2];
		if(are_connected({a}, {b, c})) {
			if(are_connected({a}, {b})) {
				edge[a].pb(b);
				edge[b].pb(a);
			} else {
				edge[a].pb(c);
				edge[c].pb(a);
			}
		} else {
			rep(j,0,N){
				if(j == b) continue;
				if(j == c) continue;
				edge[j].pb(a);
				edge[a].pb(j);
			}
		}
	}
	rep(i,0,N) shuffle(all(edge[i]), rng);
	
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

341
3 3
1
1

output:

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

result:

wrong answer 

Subtask #2:

score: 0
Wrong Answer

Test #6:

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

input:

341
3 2
1
1

output:

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

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #19:

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

input:

341
3 1
1
1

output:

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

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #83:

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

input:

341
3 1
1
1

output:

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

result:

wrong answer