QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#271218 | #7120. Soccer | LeticiaFCS | Compile Error | / | / | C++20 | 3.5kb | 2023-12-02 06:42:00 | 2024-04-28 07:58:11 |
Judging History
你现在查看的是最新测评结果
- [2024-04-28 07:58:11]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-02 06:42:00]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-02 06:42:00]
- 提交
answer
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> memo;
int point_query(int a, int b){
if(memo[a][b] != -1) return memo[a][b];
for(int c = 0; c < memo.size(); c++){
if(a == c) continue;
if(b == c) continue;
if(memo[a][c] == 0 && memo[b][c] == 0)
return memo[a][b] = memo[b][a] = 1;
}
return memo[a][b] = memo[b][a] = are_connected({a}, {b});
}
bool merge_paths(vector<int> p1, vector<int> p2, vector<int> &path){
int a = p1[0], b = p1.back();
int c = p2[0], d = p2.back();
vector<int> ends_p1, ends_p2;
if(a == b) ends_p1 = {a};
else ends_p1 = {a,b};
if(c == d) ends_p2 = {c};
else ends_p2 = {c,d};
if(!are_connected(ends_p1, ends_p2)) return false;
if(point_query(a, d)){
path = p2;
path.insert(path.end(), p1.begin(), p1.end());
return true;
}
if(point_query(b, d)){
path = p1;
path.insert(path.end(), p2.rbegin(), p2.rend());
return true;
}
reverse(p2.begin(), p2.end());
d = p2.back();
if(point_query(a, d)){
path = p2;
path.insert(path.end(), p1.begin(), p1.end());
return true;
}
return false;
}
bool merge_cycles(vector<int> c1, vector<int> c2, vector<int> &path){
if(!are_connected(c1, c2)) return false;
int a = -1, b = -1;
if(c1.size() > c2.size()) swap(c1, c2);
int n = c1.size(), m = c2.size();
for(int i = 0 ; i < n; i++){
if(!are_connected({c1[i]}, c2)) continue;
int left = 0, right = m;
while(left + 1 < right){
int mid = (left + right) / 2;
vector<int> c = c2; c.resize(mid);
if(are_connected({c1[i]}, c)) right = mid;
else left = mid;
}
a = i, b = right-1;
break;
}
if(a == -1) return false;
for(int i = (a + 1) % n; i != a; i = (i+1)%n) path.push_back(c1[i]);
path.push_back(c1[a]);
path.push_back(c2[b]);
for(int i = (b + 1) % m; i != b; i = (i+1)%m) path.push_back(c2[i]);
return true;
}
std::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){
deque<int> ans;
int start = 3;
if(are_connected({0}, {1}))
ans = {0, 1}, start = 2;
else
ans = {0, 2, 1};
for(int v = start; v < N; v++){
if(are_connected({ans.front()}, {v})) ans.push_front(v);
else ans.push_back(v);
}
return {ans.begin(), ans.end()};
}
if(D == 1){
memo = vector<vector<int>>(N+1, vector<int>(N+1, -1));
vector<vector<int>> ans = {{0}, {1}};
for(int v = 2; v < N; v++){
int a = ans[0].back();
int b = ans[1].back();
if(point_query(a, v)){
ans[0].push_back(v);
} else if(point_query(b, v))
ans[1].push_back(v);
else{
ans[0].insert(ans[0].end(), ans[1].rbegin(), ans[1].rend());
ans[1] = {v};
}
}
vector<int> path;
if(merge_paths(ans[0], ans[1], path))
return path;
if(merge_cycles(ans[0], ans[1], path))
return path;
if(ans[0].size() > ans[1].size()) return ans[0];
return ans[1];
}
return {};
}
详细
answer.code:1:10: fatal error: longesttrip.h: No such file or directory 1 | #include "longesttrip.h" | ^~~~~~~~~~~~~~~ compilation terminated.