QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#167550#7184. Transport Plusesucup-team1234#WA 2ms14792kbC++202.5kb2023-09-07 15:50:162023-09-07 15:50:17

Judging History

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

  • [2023-09-07 15:50:17]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:14792kb
  • [2023-09-07 15:50:16]
  • 提交

answer

#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
typedef long long LL;
typedef pair<int, int>PII;
typedef unsigned long long ULL; 
const int N = 1e2+10;
const int mod = 998244353;
double eps = 1e-9;
double f[N][N][N],mnx[N],mny[N];
PII pre[N][N][N];
int mnxY[N], mnyX[N];
int X[N], Y[N];
double dist(int x0,int y0,int x1,int y1)
{
	return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
}
struct P {
	int o, x, y;
};
void solve()
{
	int n, t;
	cin >> n >> t;
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 1; i <= n; i++)
		cin >> X[i] >> Y[i];
	for (int i = 0; i <= 100; i++)
	{
		mnx[i] = mny[i] = 1e9;
	}
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
		{
			f[0][i][j] = dist(sx, sy, i, j);
			pre[0][i][j] = { sx,sy };
//			cout << i << ' ' << j << ' '<< f[0][i][j] << endl;
			if (f[0][i][j] < mnx[i])
				mnx[i] = f[0][i][j], mnxY[i] = j;
			if(f[0][i][j]<mny[j])
				mny[j] = f[0][i][j],mnyX[j]=i;
		}
	for (int i = 1; i <= n; i++)
	{
		for (int x = 0; x <= 100; x++)
		{
			for (int y = 0; y <= 100; y++)
			{
				double temp= t + min(mnx[X[i]], mny[Y[i]]) + min(fabs(x - X[i]), fabs(y - Y[i]));
				f[i][x][y] = min(f[i - 1][x][y],temp);
				if (f[i - 1][x][y] <= temp)
				{
					pre[i][x][y] = pre[i - 1][x][y];
				}
				else
				{
					if (mnx[X[i]] < mny[Y[i]])
					{
						pre[i][x][y] = { X[i],mnxY[X[i]] };
					}
					else
						pre[i][x][y] = { mnyX[Y[i]],Y[i] };
				}
			}
		}

		for (int x = 0; x <= 100; x++)
			for (int y = 0; y <= 100; y++)
			{
				if (f[i][x][y] < mnx[x])
					mnx[x] = f[i][x][y], mnxY[x] = y;
				if (f[i][x][y] < mny[y])
					mny[y] = f[i][x][y], mnyX[y] = x;
			}
	}
	cout << f[n][tx][ty] << endl;
	vector<P>ans;
	for (int i = n; i; i--)
	{
		if (fabs(f[i][tx][ty] - f[i - 1][tx][ty]) < eps)
		{
			continue;
		}
		ans.push_back({ 0,tx,ty });
		int ttx = tx, tty = ty;
		if (fabs(tx - X[i]) < fabs(ty - Y[i]))
			ttx = X[i];
		else
			tty = Y[i];
		ans.push_back({ i,ttx,tty });
		ttx = tx, tty = ty;
		tx = pre[i][ttx][tty].first;
		ty = pre[i][ttx][tty].second;
	}
	ans.push_back({ 0,tx,ty });
	cout << ans.size() << endl;
	reverse(ans.begin(), ans.end());
	for (auto& [i, x, y] : ans)
		cout << i << ' ' << x << ' ' << y << endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T;
	T = 1;
	while (T--)
		solve();
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 8036kb

input:

1 2
1 1
5 3
6 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

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

input:

2 1
1 1
6 1
1 3
6 3

output:

2
5
0 1 1
1 0 3
0 0 3
2 6 1
0 6 1

result:

ok correct

Test #3:

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

input:

0 0
1 1
1 1

output:

0
1
0 1 1

result:

ok correct

Test #4:

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

input:

0 0
100 100
0 0

output:

141.421
1
0 0 0

result:

ok correct

Test #5:

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

input:

1 0
100 100
0 0
100 100

output:

100
3
0 100 100
1 0 100
0 0 0

result:

ok correct

Test #6:

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

input:

1 0
100 100
0 0
100 0

output:

0
3
0 100 100
1 0 0
0 0 0

result:

ok correct

Test #7:

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

input:

1 0
100 100
0 0
0 100

output:

0
3
0 100 100
1 0 0
0 0 0

result:

ok correct

Test #8:

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

input:

1 100
50 50
0 0
50 50

output:

70.7107
1
0 0 0

result:

ok correct

Test #9:

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

input:

1 100
50 50
0 0
0 50

output:

70.7107
1
0 0 0

result:

ok correct

Test #10:

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

input:

1 100
50 50
0 0
51 51

output:

70.7107
1
0 0 0

result:

ok correct

Test #11:

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

input:

1 100
50 50
0 0
2 53

output:

70.7107
1
0 0 0

result:

ok correct

Test #12:

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

input:

1 100
0 0
100 100
50 50

output:

141.421
1
0 100 100

result:

ok correct

Test #13:

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

input:

1 33
0 0
100 100
50 50

output:

133
3
0 0 50
1 100 50
0 100 100

result:

ok correct

Test #14:

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

input:

1 12
100 0
11 90
0 100

output:

122
3
0 100 100
1 11 100
0 11 90

result:

ok correct

Test #15:

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

input:

1 12
100 0
10 89
0 100

output:

122
3
0 100 100
1 0 89
0 10 89

result:

ok correct

Test #16:

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

input:

2 1
2 1
5 1
1 3
6 3

output:

3
1
0 5 1

result:

ok correct

Test #17:

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

input:

2 2
2 1
5 1
1 3
6 3

output:

3
1
0 5 1

result:

ok correct

Test #18:

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

input:

1 2
1 1
5 3
7 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #19:

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

input:

1 2
1 1
5 4
6 2

output:

4
3
0 1 2
1 6 4
0 5 4

result:

ok correct

Test #20:

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

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:

1
3
0 77 80
3 76 78
0 76 78

result:

ok correct

Test #21:

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

input:

5 1
40 69
37 71
37 69
36 71
38 70
40 72
40 71

output:

1
3
0 40 69
1 37 71
0 37 71

result:

ok correct

Test #22:

score: 0
Accepted
time: 2ms
memory: 6568kb

input:

8 1
84 27
86 32
85 31
83 27
86 27
85 28
83 27
83 32
85 31
87 29

output:

1
3
0 84 27
3 86 32
0 86 32

result:

ok correct

Test #23:

score: 0
Accepted
time: 2ms
memory: 7124kb

input:

11 1
95 30
99 36
96 33
95 36
94 30
98 33
98 36
97 31
99 33
99 31
98 35
95 36
100 32

output:

1
3
0 95 30
2 99 36
0 99 36

result:

ok correct

Test #24:

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

input:

4 1
19 37
18 32
18 36
21 36
19 33
22 34

output:

2
3
0 19 36
1 18 32
0 18 32

result:

ok correct

Test #25:

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

input:

7 1
49 6
48 8
46 3
49 9
45 6
43 3
49 8
43 8
48 2

output:

1
3
0 49 6
5 48 8
0 48 8

result:

ok correct

Test #26:

score: 0
Accepted
time: 2ms
memory: 11076kb

input:

10 0
75 31
74 34
77 36
79 34
74 37
75 32
76 31
81 37
79 34
77 28
80 36
80 28

output:

0
5
0 75 31
4 75 34
0 75 34
7 74 34
0 74 34

result:

ok correct

Test #27:

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

input:

3 3
74 19
75 15
70 17
74 10
75 17

output:

4
3
0 74 19
2 74 15
0 75 15

result:

ok correct

Test #28:

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

input:

6 1
38 6
35 3
32 13
34 4
37 4
28 10
37 12
35 14

output:

3
3
0 37 6
3 35 4
0 35 3

result:

ok correct

Test #29:

score: 0
Accepted
time: 2ms
memory: 6712kb

input:

9 2
91 54
90 52
86 61
90 59
90 63
97 54
93 60
96 56
85 63
89 58
95 59

output:

2.23607
1
0 90 52

result:

ok correct

Test #30:

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

input:

3 1
28 85
24 87
23 94
29 87
23 86

output:

2
3
0 29 85
2 24 87
0 24 87

result:

ok correct

Test #31:

score: 0
Accepted
time: 2ms
memory: 10984kb

input:

18 1
56 70
54 77
56 72
52 71
54 69
53 67
52 72
55 73
51 71
59 74
49 77
58 80
59 72
60 77
50 70
56 71
61 71
63 79
60 76
54 69

output:

2
3
0 56 69
3 54 77
0 54 77

result:

ok correct

Test #32:

score: 0
Accepted
time: 2ms
memory: 10972kb

input:

28 1
70 72
62 63
78 73
80 64
74 74
55 60
77 55
58 61
64 57
68 65
75 73
64 75
76 60
77 58
60 65
64 67
79 66
58 78
64 58
66 55
62 62
55 57
65 55
73 76
58 70
76 56
66 68
77 76
64 55
55 65

output:

3
5
0 70 73
1 78 62
0 78 62
19 62 63
0 62 63

result:

ok correct

Test #33:

score: -100
Wrong Answer
time: 1ms
memory: 14792kb

input:

40 1
72 56
63 68
70 58
70 63
55 55
52 76
83 52
84 86
49 66
63 76
57 65
82 77
50 78
82 76
78 53
74 58
66 65
80 71
57 77
54 71
77 86
67 88
71 71
80 74
65 70
48 66
80 86
82 69
72 78
72 73
74 65
84 49
68 75
47 52
75 82
83 55
52 76
49 88
47 48
70 61
45 60
44 49

output:

3
5
0 72 55
3 55 76
0 55 76
8 63 68
0 63 68

result:

wrong answer read 3.000000 but expected 2.000000, error = 1.000000