QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#675141 | #7184. Transport Pluses | liaoyd | Compile Error | / | / | C++98 | 5.7kb | 2024-10-25 18:01:36 | 2024-10-25 18:01:37 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
#define double long double
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef const double* (*p_fun)(const double*, int);
const LL N = 3e3 + 10, M = 2e3 + 10, mod = 1e9 + 7, LLF = 1e15,
null = 0x3f3f3f3f3f3f3f;
template <typename T>
bool chmax(T& a, const T& b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T, typename... Args>
bool chmax(T& a, const T& b, const Args&... args) {
bool updated = chmax(a, b);
return chmax(a, args...) || updated;
}
template <typename T>
bool chmin(T& a, const T& b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T, typename... Args>
bool chmin(T& a, const T& b, const Args&... args) {
bool updated = chmin(a, b);
return chmin(a, args...) || updated;
}
class UnionFind {
public:
vector<int> parent;
vector<int> size;
int n;
// 当前连通分量数目
int setCount;
public:
UnionFind(int _n) : n(_n), setCount(_n), parent(_n), size(_n, 1) {
iota(parent.begin(), parent.end(), 0);
}
int find(int x) { return parent[x] == x ? x : parent[x] = find(parent[x]); }
bool merge(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return false;
if (size[x] < size[y]) swap(x, y);
parent[y] = x;
size[x] += size[y];
--setCount;
return true;
}
bool connected(int x, int y) {
x = find(x);
y = find(y);
return x == y;
}
};
int qmi(int a, int b) {
int res = 1;
a %= mod;
while (b) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
int sqrt(int x) {
int l = 0, r = 3e9; // LLONG_MAX
while (l < r) {
int mid = (l + r + 1) >> 1;
if (mid * mid > x)
r = mid - 1; // 向下取整
else
l = mid;
}
return r;
}
struct node {
int op;
double x, y;
};
double dis(double& bgx, double& bgy, double& edx, double& edy) {
return sqrt(pow(bgx - edx, 2) + pow(bgy - edy, 2));
}
static inline void solve() {
int n;
double t;
cin >> n >> t;
double bgx, bgy, edx, edy;
cin >> bgx >> bgy >> edx >> edy;
vector<pii> v(n + 1);
for (int i = 1; i <= n; i++)
cin >> v[i].x >> v[i].y;
vector<vector<node>> ans(4);
double s1 = dis(bgx, bgy, edx, edy);
ans[1].push_back({ 0,edx,edy });
node t1 = {}, t2 = {};
int posj = 0, posy = 0, mnj = LLF, mny = LLF, mn2 = LLF;
double x2 = LLF;
int jl = 0;
for (int i = 1; i <= n; i++) {
double disx = abs(v[i].x - bgx), disy = abs(v[i].y - bgy);
double s2 = min(disx, disy);
double disxf = abs(v[i].x - edx), disyf = abs(v[i].y - edy);
double s2f = min(disxf, disyf);
x2 = min(x2, s2 + s2f + t);
if (x2 == s2 + s2f + t) {
jl = i;
}
}
int z1, y1;
double an1 = LLF, an2 = LLF;
for (int i = 1; i <= n; i++) {
double disx = abs(v[i].x - bgx), disy = abs(v[i].y - bgy);
double s2 = min(disx, disy);
double disxf = abs(v[i].x - edx), disyf = abs(v[i].y - edy);
double s2f = min(disxf, disyf);
an1 = min(an1, s2);
an2 = min(an2, s2f);
if (an1 == s2) { z1 = i; }
if (an2 == s2f) { y1 = i; }
}
double ans3 = min(abs(v[z1].x - bgx) , abs(v[z1].y - bgy)) + min(abs(v[y1].x - edx) , abs(v[y1].y - edy)) + 2 * t;
double aan = min({ ans3,s1,x2 });
//cout << aan << "\n";
cout << fixed << setprecision(5) << aan << endl;
if (aan == s1) {
cout << ans[1].size() << "\n";
for (auto e : ans[1]) {
cout << e.op << " " << e.first << " " << e.second << "\n";
}
}
else if (aan == x2) {
if (abs(v[jl].x - bgx) <= abs(v[jl].y - bgy)) {
node ta = { 0,v[jl].x,bgy };
ans[2].push_back(ta);
}
else {
node ta = { 0,bgx,v[jl].y };
ans[2].push_back(ta);
}
if (abs(v[jl].x - edx) <= abs(v[jl].y - edy)) {
node ta = { jl,v[jl].x,edy };
ans[2].push_back(ta);
}
else {
node ta = { jl,edx,v[jl].y };
ans[2].push_back(ta);
}
node ta = { 0,edx,edy };
ans[2].push_back(ta);
cout << ans[2].size() << "\n";
for (auto e : ans[2]) {
cout << e.op << " " << e.first << " " << e.second << "\n";
}
}
else {
if (abs(v[z1].x - bgx) <= abs(v[z1].y - bgy)) {
node ta = { 0,v[z1].x,bgy };
ans[3].push_back(ta);
}
else {
node ta = { 0,bgx,v[z1].y };
ans[3].push_back(ta);
}
node ta = { z1, v[z1].x,v[y1].y };
ans[3].push_back({ ta });
if (abs(v[y1].x - edx) <= abs(v[y1].y - edy)) {
node ta = { y1,edx,v[y1].y };
ans[3].push_back(ta);
}
else {
node ta = { y1,v[y1].x,v[y1].y };
ans[3].push_back(ta);
}
ta = { 0,edx,edy };
ans[3].push_back(ta);
cout << ans[3].size() << "\n";
for (auto e : ans[3]) {
cout << e.op << " " << e.first << " " << e.second << "\n";
}
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << unitbuf;
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
Details
answer.code:22:31: warning: variadic templates only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 22 | template <typename T, typename... Args> | ^~~ answer.code:23:45: warning: variadic templates only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 23 | bool chmax(T& a, const T& b, const Args&... args) { | ^~~~ answer.code:35:31: warning: variadic templates only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 35 | template <typename T, typename... Args> | ^~~ answer.code:36:45: warning: variadic templates only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 36 | bool chmin(T& a, const T& b, const Args&... args) { | ^~~~ answer.code: In constructor ‘UnionFind::UnionFind(long long int)’: answer.code:50:9: error: ‘iota’ was not declared in this scope 50 | iota(parent.begin(), parent.end(), 0); | ^~~~ answer.code: In function ‘void solve()’: answer.code:114:23: error: ‘>>’ should be ‘> >’ within a nested template argument list 114 | vector<vector<node>> ans(4); | ^~ | > > answer.code:117:22: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 117 | ans[1].push_back({ 0,edx,edy }); | ^ answer.code:117:21: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 117 | ans[1].push_back({ 0,edx,edy }); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ answer.code:146:22: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 146 | double aan = min({ ans3,s1,x2 }); | ^ answer.code:146:21: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’ 146 | double aan = min({ ans3,s1,x2 }); | ~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:146:21: note: candidate expects 2 arguments, 1 provided 146 | double aan = min({ ans3,s1,x2 }); | ~~~^~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:146:21: note: candidate expects 3 arguments, 1 provided 146 | double aan = min({ ans3,s1,x2 }); | ~~~^~~~~~~~~~~~~~~~ answer.code:152:19: error: ‘e’ does not name a type 152 | for (auto e : ans[1]) { | ^ answer.code:154:10: error: expected ‘;’ before ‘}’ token 154 | } | ^ | ; 155 | } | ~ answer.code:155:5: error: expected primary-expression before ‘}’ token 155 | } | ^ answer.code:154:10: error: expected ‘;’ before ‘}’ token 154 | } | ^ | ; 155 | } | ~ answer.code:155:5: error: expected primary-expression before ‘}’ token 155 | } | ^ answer.code:154:10: error: expected ‘)’ before ‘}’ token 154 | } | ^ | ) 155 | } | ~ answer.code:152:13: note: to match this ‘(’ 152 | for (auto e : ans[1]) { | ^ answer.code:155:5: error: expected primary-expression before ‘}’ token 155 | } | ^ answer.code:177:19: error: ‘e’ does not name a type 177 | for (auto e : ans[2]) { | ^ answer.code:179:10: error: expected ‘;’ before ‘}’ token 179 | } | ^ | ; 180 | } | ~ answer.code:180:5: error: expected primary-expression before ‘}’ token 180 | } | ^ answer.code:179:10: error: expected ‘;’ before ‘}’ token 179 | } | ^ | ; 180 | } | ~ answer.code:180:5: error: expected primary-expression before ‘}’ token 180 | } | ^ answer.code:179:10: error: expected ‘)’ before ‘}’ token 179 | } | ^ | ) 180 | } | ~ an...