QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#167663 | #6412. Classical Geometry Problem | realIyxiang# | WA | 1ms | 3684kb | C++14 | 2.4kb | 2023-09-07 16:29:02 | 2023-09-07 16:29:02 |
Judging History
answer
#include <bits/stdc++.h>
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)
using namespace std;
using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;
template < typename T > T read() {
T x = 0; bool f = 0; char ch = getchar();
while(!isdigit(ch)) f |= ch == '-', ch = getchar();
while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }
const int N = 1e6 + 10;
const db eps = 1e-7;
bool cqu(db x, db y) { return fabs(x - y) < eps; }
struct ve {
db x, y, z;
ve(db _x, db _y, db _z) : x(_x), y(_y), z(_z) { }
db len() { return sqrt(x * x + y * y + z * z); }
friend ve operator - (ve a, ve b) { return ve(a.x - b.x, a.y - b.y, a.z - b.z); }
friend ve operator + (ve a, ve b) { return ve(a.x + b.x, a.y + b.y, a.z + b.z); }
friend ve operator * (ve a, db b) { return ve(a.x * b, a.y * b, a.z * b); }
friend bool operator == (ve a, ve b) {
return cqu(a.x, b.x) & cqu(a.y, b.y) & cqu(a.z, b.z);
}
void set1() { db t = len(); t = 1 / t; x *= t, y *= t, z *= t; }
};
void solve() {
ve t(0, 0, 0); t.x = in, t.y = in, t.z = in;
vector < pair < db, ve > > ans;
auto output = [&]() {
printf("%d\n", ans.size());
for(auto v : ans) printf("%.0lf %.0lf %.0lf %.11lf\n", v.se.x, v.se.y, v.se.z, v.fi);
};
ve g1(255 + eps, 255 + eps, 255 + eps);
if(g1 == t) return output();
ve p = g1 - t; p.set1();
db ret = min({ t.x / p.x, t.y / p.y, t.z / p.z });
ans.eb(ret, g1); // reverse pos
t = t - p * ret;
ve g2 = g1;
if(cqu(t.x, 0)) g2.x = eps; if(cqu(t.y, 0)) g2.y = eps; if(cqu(t.z, 0)) g2.z = eps;
//if(t == ve(0, 0, 0)) return output();
p = g2 - t; p.set1();
ret = min({ t.x / p.x, t.y / p.y, t.z / p.z });
ans.eb(ret, g2);
t = t - p * ret;
ve g3 = g2;
if(cqu(t.x, 0)) g3.x = eps; if(cqu(t.y, 0)) g3.y = eps; if(cqu(t.z, 0)) g3.z = eps;
ans.eb(t.len(), g3);
reverse(ans.begin(), ans.end()); output();
}
int main() {
#ifdef YJR_2333_TEST
freopen("1.in", "r", stdin);
#endif
for(int T = in; T; T--) solve(); return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3684kb
input:
3 105 255 175 174 174 174 0 0 0
output:
3 0 255 255 281.40007099595 0 255 255 0.00000000000 255 255 255 119.00000001537 3 0 0 0 0.00000000000 0 0 0 0.00000000000 255 255 255 301.37684051698 3 0 0 0 0.00000000000 0 0 0 0.00000000000 255 255 255 0.00000000000
result:
wrong answer too far from the target: (113.641720, 223.945470, 223.945470) instead of (105, 255, 175) (test case 1)