QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#155794 | #7119. Longest Trip | HossamHero7 | Compile Error | / | / | C++14 | 1.8kb | 2023-09-02 05:58:35 | 2024-04-28 07:45:43 |
Judging History
你现在查看的是最新测评结果
- [2024-04-28 07:45:43]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-02 05:58:36]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-02 05:58:35]
- 提交
answer
#include <bits/stdc++.h>
#include "longesttrip.h"
#include "grader.cpp"
using namespace std;
typedef long long ll;
vector<vector<int>> adj;
vector<bool> vis;
vector<vector<int>> p;
vector<int> pp;
void dfs(int node){
pp.push_back(node);
vis[node] = 1;
for(auto ch : adj[node]){
if(vis[ch]) continue;
dfs(ch);
break;
}
}
vector<int> longest_trip(int n, int d)
{
if(d == 3) {
vector<int> ans(n);
iota(ans.begin(),ans.end(),0);
return ans;
}
if(d == 2){
vector<int> a;
vector<int> b;
vector<bool> rem(n,1);
vector<int> ans;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(!are_connected({i},{j})) {
a.push_back(i);
b.push_back(j);
rem[i] = 0;
rem[j] = 0;
}
}
}
for(auto i : a) ans.push_back(i);
for(int i=0;i<n;i++) if(rem[i]) ans.push_back(i);
for(auto i : b) ans.push_back(i);
return ans;
}
adj.clear();
adj.resize(n);
vis.clear();
vis.resize(n);
p.clear();
for(int i=0;i<n;i++){
if(vis[i]) continue;
pp.clear();
dfs(i);
p.push_back(pp);
}
vector<int> ans;
for(auto a : p){
vector<bool> vis(n);
int i = 0;
while(!vis[i]){
vis[i] = 1;
ans.push_back(a[i]);
i += 2;
if(i>=a.size()) i -= a.size();
}
if(a.size()>4 && a.size()%2==0){
i = 1;
while(!vis[i]){
vis[i] = 1;
ans.push_back(a[i]);
i += 2;
if(i>=a.size()) i -= a.size();
}
}
}
return ans;
}
詳細信息
answer.code:3:10: fatal error: grader.cpp: No such file or directory 3 | #include "grader.cpp" | ^~~~~~~~~~~~ compilation terminated.