QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309660#8022. WalkerEbiarat#TL 1ms3896kbC++202.7kb2024-01-20 19:38:372024-01-20 19:38:37

Judging History

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

  • [2024-01-20 19:38:37]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3896kb
  • [2024-01-20 19:38:37]
  • 提交

answer

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <sstream>
#include <ctime>
#include <iterator>
#include <string.h>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <fstream>
#include <assert.h>
#include <numeric>
#include <complex>
#include <random>
#include <utility>
#define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define VI vector<int>
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VL vector<long long >
#define FILL(a, value) memset(a, value, sizeof(a))
const int nax = (int)1e3 + 147;

using namespace std;

const int MOD = (int)1e9 + 7;
const int INF = 1e9 +47 ;
const long long LINF = (long long)1e18 + 4747;

typedef long long LL;

vector<int >g[nax];
int ignored[nax];
int ign_cnt[nax];
int sz[nax];
int ans[nax];
map<pair<int,int>,bool> edge;
bool is_vertex[nax];
map<string,int> known;
void dfs(int v)
{
    sz[v] = g[v].empty();
    ign_cnt[v] = ignored[v];
    for(auto to : g[v])
    {
        dfs(to);
        sz[v]+=sz[to];
        ign_cnt[v]+=ign_cnt[to];
    }
    if(ign_cnt[v] == sz[v] && v != 1)ans[v] = 1;
    else {
        for(auto to : g[v])ans[v] += ans[to];
        if(ignored[v])ans[v]++;
    }
 }
void solve()
{
    double n, p1, v1, p2, v2 ;
    cin >> n >> p1 >> v1 >> p2 >> v2;
    if(p1>p2) {
        swap(v1,v2);
        swap(p1,p2);
    }
    double ans1, ans2, ans3, ans5, ans6, ans7;
    ans1 = (n + min(p1, n-p1))/v1;
    ans2 = (n + min(p2, n-p2))/v2;
    ans7 = max((n-p1)/v1, p2/v2 );
    double l = p1, r = p2;
    while (r-l > 1e-12)
    {
        double mid1 = l+ (r-l)/3.0;
        double mid2 = l+ 2*(r-l)/3.0;

        double mid1_ans = (min((mid1-p1), p1) + mid1)/v1;
        mid1_ans = max(mid1_ans, (min(n-p2, p2-mid1) + n-mid1)/v2);

        double mid2_ans = (min((mid2-p1), p1) + mid2)/v1;
        mid2_ans = max(mid2_ans, (min(n-p2, p2-mid2) + n-mid2)/v2);

        if (mid1_ans < mid2_ans)
            r = mid2;
        else
            l = mid1;
    }
    double t_ans = (min((l-p1), p1) + l)/v1;
    t_ans = max(t_ans, (min(n-p2, p2-l) + n-l)/v2);

        cout << fixed << setprecision(10) << min({ans1, ans2, ans7, t_ans}) << endl;

}
int main() {
    IOS;
    int tt = 1;
    cin >> tt;
    while(tt--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3764kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.0000000000
3827.8370013755

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.1000000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.2000000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

1
10.0 8.0 0.1 9.0 10

output:

1.1000000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

1
10.0 2.0 0.1 3.0 10

output:

1.3000000000

result:

ok found '1.3000000', expected '1.3000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.2000000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.0000000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1
10.0 4.5 0.1 6.0 0.1

output:

57.5000000000

result:

ok found '57.5000000', expected '57.5000000', error '0.0000000'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

1
10.0 1.0 1.0 8.0 1.0

output:

6.5000000000

result:

ok found '6.5000000', expected '6.5000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1
10.0 3.0 2.0 7.0 1.0

output:

4.6000000000

result:

ok found '4.6000000', expected '4.6000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

1
10.0 6.0 2.0 7.0 1.0

output:

3.6666666667

result:

ok found '3.6666667', expected '3.6666667', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

1
10.0 1.0 1.0 9.0 1.0

output:

6.0000000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

1
10000.0 1.0 0.001 1.0 0.001

output:

9999000.0000000000

result:

ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

1
10.0 5.0 1.0 5.0 1.5

output:

5.0000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #15:

score: -100
Time Limit Exceeded

input:

10000
4306.063 4079.874 0.607 1033.423 0.847
8967.336 8026.500 0.398 283.019 0.876
9568.147 4481.616 0.405 800.114 0.684
9867.264 6184.040 0.312 9853.164 0.641
3344.364 730.612 0.539 1305.868 0.947
9336.180 3672.113 0.773 432.686 0.312
1468.243 59.762 0.840 1438.446 0.827
1355.133 1096.314 0.373 109...

output:

3827.8370013755
7999.3649921507
12559.3358024691
15371.5507020281
2637.6985195155
9931.0415175376
934.4943011398
2939.1796246649
5754.0328898744
2847.4271570014
10975.3236282195
2180.2786069652
23747.0454545455
6278.1035548686
872.3977055449
10734.3956442831
1005.0770288858
20225.1630901288
9878.009...

result: