QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500758#6412. Classical Geometry Problemucup-team2307#WA 1ms3800kbC++202.8kb2024-08-01 19:43:182024-08-01 19:43:20

Judging History

你现在查看的是最新测评结果

  • [2024-08-01 19:43:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3800kb
  • [2024-08-01 19:43:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pii = pair<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define pb push_back

double N = 255;
double EPS = 1e-3;
double dist(double x, double y)
{
    return sqrt(x*x+y*y);
}
double dist(double x, double y, double z)
{
    return sqrt(x*x+y*y+z*z);
}
double dist(double x1, double y1, double x2, double y2)
{
    return dist(x1-x2, y1-y2);
}
vector<array<double, 3> > solve2(double x, double y)
{
    if (abs(x)+abs(y)<EPS)
        return {};
    vector<array<double, 3> > ans;
    if (x > y)
    {
        double t = N/x*y;
        ans.pb({N, 0, 3*N});
        ans.pb({N, N, t});
        ans.pb({0, 0, dist(x, y, N, t)});
    }
    else
    {
        double t = N/y*x;
        ans.pb({0, N, 3*N});
        ans.pb({N, N, t});
        ans.pb({0, 0, dist(x, y, t, N)});
    }
    return ans;
}

void add(vector<array<double, 4> >& v, vector<array<double, 3> > a, int id)
{
    for (auto b : a)
    {
        array<double, 4> c;
        for (int i=0; i<3; i++)
            c[i + (i>=id)] = b[i];
        c[id] = N;

        v.pb(c);
    }
}

vector<array<double, 4> > solve3(double x, double y, double z)
{
    if (abs(x)+abs(y)+abs(z)<EPS)
        return {};
    vector<array<double, 4> > ans;
    if (x >= y && x >= z)
    {
        ans.pb({N, 0, 0, 3*N});
        double t = N/x;
        add(ans, solve2(t*y, t*z), 0);
        ans.pb({0, 0, 0, dist(N-x, t*y-y, t*z-z)});
    }
    else if (y >= x && y >= z)
    {
        ans.pb({0, N, 0, 3*N});
        double t = N/y;
        add(ans, solve2(t*x, t*z), 1);
        ans.pb({0, 0, 0, dist(t*x-x, N-y, t*z-z)});
    }
    else
    {
        ans.pb({0, 0, N, 3*N});
        double t = N/z;
        add(ans, solve2(t*x, t*y), 2);
        ans.pb({0, 0, 0, dist(t*x-x, t*y-y, N-z)});
    }
    return ans;
}

void sim(double& x, double& y, double& z, double a, double b, double c, double t)
{
    double v = dist(a-x, b-y, c-z);
    t = min(t, v);
    x += (a-x)*t/v;
    y += (b-y)*t/v;
    z += (c-z)*t/v;
}

void solve()
{
    double x, y, z;
    cin>>x>>y>>z;
    auto ans = solve3(x, y, z);
    cout<<ans.size()<<"\n";
    for (auto a : ans)
        cout<<int(a[0]+0.5)<<" "<<int(a[1]+0.5)<<" "<<int(a[2]+0.5)<<" "<<a[3]<<"\n";

    x = y = z = 0;
    for (auto a : ans)
         sim(x, y, z, a[0], a[1], a[2], a[3]);
    cout<<x<<" "<<y<<" "<<z<<"\n";
}

signed main()
{
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
    cout<<fixed<<setprecision(10);

    int t;
    cin>>t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3800kb

input:

3
105 255 175
174 174 174
0 0 0

output:

5
0 255 0 765.0000000000
0 255 255 765.0000000000
255 255 255 153.0000000000
0 255 0 93.2952303175
0 0 0 0.0000000000
105.0000000000 255.0000000000 175.0000000000
5
255 0 0 765.0000000000
255 0 255 765.0000000000
255 255 255 255.0000000000
255 0 0 0.0000000000
0 0 0 140.2961154131
174.0000000000 174...

result:

wrong output format Expected integer, but "105.0000000000" found (test case 2)