ReiAC's Blog

Recent content on ReiAC's Blog

马上订阅 ReiAC's Blog RSS 更新: https://rei.ac/index.xml

牛客 1041D MobileService

2021年1月31日 00:43

题目链接:Mobile Service

这个题最简单的想法就是直接把三个人的位置直接都放进状态,然而这样子的话复杂度到了$O(N*L^3)$实在是难以接受的复杂度。

我们发现,员工的位置只要知道两个没有去服务上一个p[i]的人,第三个人一定在p[i]位置,因此我们知道其复杂度变为了$O(N*L^2)$已经是可以接受的状态了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#define int long long
//#define int __int128
#define ull unsigned long long
#define mmst0(x) memset(x,0,sizeof(x))
#define mmst3f(x) memset(x,0x3f,sizeof(x))
#define pb(x) push_back(x)

using namespace std;
//using namespace __gnu_pbds;

const int INF...

剩余内容已隐藏

查看完整文章以阅读更多