QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468936#7184. Transport PlusesembuscaWA 0ms3976kbC++203.8kb2024-07-09 05:06:132024-07-09 05:06:13

Judging History

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

  • [2024-07-09 05:06:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3976kb
  • [2024-07-09 05:06:13]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define rep(i, begin, end) for(int i = begin; i < end; i++)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sq(x) (x)*(x)

const int N = 112345;
const int inf = 1e9+7;

void solvetask()
{
    int n, t;
    cin >> n >> t;

    array<int,2> ini, fim;
    cin >> ini[0] >> ini[1];
    cin >> fim[0] >> fim[1];

    vector<array<int,2>> plus(n);
    rep(i,0,n) cin >> plus[i][0] >> plus[i][1];
    int mini = 1e9, ind_mini = 0;

    rep(i,0,n){
        if(min(abs(fim[0] - plus[i][0]), abs(fim[1] - plus[i][1])) < mini){
            ind_mini = i;
            mini = min(abs(fim[0] - plus[i][0]), abs(fim[1] - plus[i][1]));
        }
    }
    // cout << "M " << mini << '\n';
    int res = 1e9;
    int oto = -1;
    rep(i,0,n){
        int dist_ini = min(abs(ini[0] - plus[i][0]), abs(ini[1] - plus[i][1]));
        int dist_fim = min(abs(fim[0] - plus[i][0]), abs(fim[1] - plus[i][1]));
        // cout << "INI " << dist_ini << " FIM " << dist_fim << " T " << t<< '\n';
        if(i == ind_mini){
            if(dist_ini + t + dist_fim < res){
                oto = -1;
                res = dist_ini + t + dist_fim;
            }
        }
        if(dist_ini + mini + 2*t < res){
            oto = i;
            res = dist_ini + mini + 2*t;
        }
    }

    long double aux = sqrtl(sq(ini[0]-fim[0]) + sq(ini[1]-fim[1]));

    cout << fixed << setprecision(6);
    // cout << aux << '\n';
    if((long double)res > aux){
        cout << aux << '\n';
        cout << 1 << '\n';
        cout << 0 << " " << fim[0] << " " << fim[1] << '\n';
        return;
    }

    cout << (long double)res << '\n';
    if(oto == -1){
        bool cond1 = fim[0] == plus[ind_mini][0] || fim[1] == plus[ind_mini][1];
        bool cond2 = ini[0] == plus[ind_mini][0] || ini[1] == plus[ind_mini][1];
        cout << 3 - cond1 - cond2 << '\n';
        if(!cond2){
            if(abs(ini[0] - plus[ind_mini][0]) < abs(ini[1] - plus[ind_mini][1])){
                cout << 0 << " " << plus[ind_mini][0] << " " << ini[1] << '\n';
            }else
                cout << 0 << " "<< ini[0] << " " << plus[ind_mini][1] << '\n';
        }

        if(abs(fim[0] - plus[ind_mini][0]) < abs(fim[1] - plus[ind_mini][1])){
            cout << ind_mini + 1 << " " << plus[ind_mini][0] << " " << fim[1] << '\n';
        }else
            cout << ind_mini + 1 << " "<< fim[0] << " " << plus[ind_mini][1] << '\n';

        if(!cond1)
        cout << 0 << " " << fim[0] << " " << fim[1] << '\n';
    }else{
        bool cond1 = fim[0] == plus[ind_mini][0] || fim[1] == plus[ind_mini][1];
        bool cond2 = ini[0] == plus[oto][0] || ini[1] == plus[oto][1];
        // cout << ini[0] << " " << plus[oto][0] << " " <<  ini[1] << " " << plus[oto][1] << '\n';
        cout << 4 - cond1 - cond2 << '\n';
        if(!cond2)
            if(abs(ini[0] - plus[oto][0]) < abs(ini[1] - plus[oto][1])){
                cout << 0 << " " << plus[oto][0] << " " << ini[1] << '\n';
            }else
                cout << 0 << " "<< ini[0] << " " << plus[oto][1] << '\n';

        cout << oto +1 << " " << plus[oto][0] << " " << plus[ind_mini][1] << '\n'; 

        if(abs(fim[0] - plus[ind_mini][0]) < abs(fim[1] - plus[ind_mini][1])){
            cout << ind_mini + 1 << " " << plus[ind_mini][0] << " " << fim[1] << '\n';
        }else
            cout << ind_mini + 1 << " "<< fim[0] << " " << plus[ind_mini][1] << '\n';

        if(!cond1)
        cout << 0 << " " << fim[0] << " " << fim[1] << '\n';
    }

}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solvetask();
        // cout << (solvetask() ? "Yes" : "No") << '\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3976kb

input:

1 2
1 1
5 3
6 2

output:

4.000000
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

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

input:

2 1
1 1
6 1
1 3
6 3

output:

2.000000
2
1 1 3
2 6 1

result:

ok correct

Test #3:

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

input:

0 0
1 1
1 1

output:

0.000000
1
0 1 1

result:

ok correct

Test #4:

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

input:

0 0
100 100
0 0

output:

141.421356
1
0 0 0

result:

ok correct

Test #5:

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

input:

1 0
100 100
0 0
100 100

output:

100.000000
2
1 0 100
0 0 0

result:

ok correct

Test #6:

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

input:

1 0
100 100
0 0
100 0

output:

0.000000
1
1 0 0

result:

ok correct

Test #7:

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

input:

1 0
100 100
0 0
0 100

output:

0.000000
1
1 0 0

result:

ok correct

Test #8:

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

input:

1 100
50 50
0 0
50 50

output:

70.710678
1
0 0 0

result:

ok correct

Test #9:

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

input:

1 100
50 50
0 0
0 50

output:

70.710678
1
0 0 0

result:

ok correct

Test #10:

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

input:

1 100
50 50
0 0
51 51

output:

70.710678
1
0 0 0

result:

ok correct

Test #11:

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

input:

1 100
50 50
0 0
2 53

output:

70.710678
1
0 0 0

result:

ok correct

Test #12:

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

input:

1 100
0 0
100 100
50 50

output:

141.421356
1
0 100 100

result:

ok correct

Test #13:

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

input:

1 33
0 0
100 100
50 50

output:

133.000000
3
0 0 50
1 100 50
0 100 100

result:

ok correct

Test #14:

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

input:

1 12
100 0
11 90
0 100

output:

122.000000
3
0 100 100
1 11 100
0 11 90

result:

ok correct

Test #15:

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

input:

1 12
100 0
10 89
0 100

output:

122.000000
3
0 100 100
1 0 89
0 10 89

result:

ok correct

Test #16:

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

input:

2 1
2 1
5 1
1 3
6 3

output:

3.000000
1
0 5 1

result:

ok correct

Test #17:

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

input:

2 2
2 1
5 1
1 3
6 3

output:

3.000000
1
0 5 1

result:

ok correct

Test #18:

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

input:

1 2
1 1
5 3
7 2

output:

4.000000
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #19:

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

input:

1 2
1 1
5 4
6 2

output:

4.000000
3
0 1 2
1 6 4
0 5 4

result:

ok correct

Test #20:

score: -100
Wrong Answer
time: 0ms
memory: 3888kb

input:

12 1
77 80
76 78
77 81
76 79
77 78
75 80
75 79
76 80
78 81
77 81
76 81
76 80
77 79
76 79

output:

2.000000
2
1 77 79
2 76 78

result:

wrong answer read 2.000000 but expected 1.000000, error = 1.000000