QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500755#6412. Classical Geometry Problemucup-team2307#WA 31ms3920kbC++202.8kb2024-08-01 19:37:502024-08-01 19:37:53

Judging History

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

  • [2024-08-01 19:37:53]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3920kb
  • [2024-08-01 19:37:50]
  • 提交

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<<endl;
}

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: 100
Accepted
time: 0ms
memory: 3724kb

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
5
0 0 255 765.0000000000
0 255 255 765.0000000000
255 255 255 255.0000000000
0 0 255 0.0000000000
0 0 0 140.2961154131
0

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 3920kb

input:

10000
250 128 13
1 245 2
88 183 138
179 69 194
153 246 33
255 119 192
233 30 108
26 208 33
53 162 189
225 130 10
202 137 121
152 198 25
49 165 180
228 56 30
74 18 14
6 115 31
168 242 206
90 238 139
44 103 60
16 21 190
229 209 68
41 171 181
39 74 73
181 96 18
234 95 70
75 174 84
101 16 44
202 249 80
...

output:

5
255 0 0 765.0000000000
255 255 0 765.0000000000
255 255 255 25.8984375000
255 0 0 125.0801491142
0 0 0 5.6232730682
5
0 255 0 765.0000000000
0 255 255 765.0000000000
255 255 255 127.5000000000
0 255 0 282.7713310730
0 0 0 10.0004164845
5
0 255 0 765.0000000000
0 255 255 765.0000000000
255 255 255 ...

result:

wrong answer too far from the target: (0.000000, 0.000000, 0.000000) instead of (132, 132, 85) (test case 1631)