QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#217467 | #7119. Longest Trip | hocky# | 0 | 1ms | 3956kb | C++14 | 1.2kb | 2023-10-16 21:27:09 | 2023-10-16 21:27:09 |
Judging History
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;
}
詳細信息
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 0 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 0
result:
wrong answer
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3872kb
input:
341 3 2 1 1
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 2 2 0 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 0
result:
wrong answer
Subtask #3:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 0ms
memory: 3956kb
input:
341 3 1 1 1
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 2 2 0 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 0
result:
wrong answer
Subtask #4:
score: 0
Wrong Answer
Test #83:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
341 3 1 1 1
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 2 2 0 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 0
result:
wrong answer