Skip to content

Commit a47df16

Browse files
committed
update acwc48
1 parent da1f09b commit a47df16

File tree

3 files changed

+165
-2
lines changed

3 files changed

+165
-2
lines changed

acwing/48.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# acwing48场周赛
2+
3+
4+
5+
### T1
6+
7+
直接模拟
8+
9+
```cpp
10+
11+
void solve(){
12+
int n, k;
13+
cin >> n >> k;
14+
for(int i = n; i <= 1000; i++){
15+
double d = i/k;
16+
if(n + d <= i) {
17+
cout << i << endl;
18+
return;
19+
}
20+
}
21+
22+
}
23+
```
24+
25+
### T2
26+
27+
周期出现为6
28+
29+
```cpp
30+
void solve(){
31+
int n, x;
32+
cin >> n >> x;
33+
int r = n % 6;
34+
int a[3] = {0, 0, 0};
35+
a[x] = 1;
36+
while(r--){
37+
if(n & 1) swap(a[0], a[1]);
38+
else swap(a[1], a[2]);
39+
n--;
40+
}
41+
int ans = 0;
42+
for(int i = 0; i < 3; i++) if(a[i] == 1) ans = i;
43+
cout << ans << endl;
44+
}
45+
```
46+
47+
48+
49+
### T3
50+
51+
贪心,但是卡哈希了,搞得我还一直以为是我用了dfs
52+
53+
先离散化了一下,用处不大..
54+
55+
```cpp
56+
static constexpr int mod = 998244353;
57+
void solve(){
58+
int n;
59+
cin >> n;
60+
vector <int> a(n);
61+
for(int i = 0; i < n; i++) cin >> a[i];
62+
set <int> st;
63+
for(int i: a) st.insert(i);
64+
map <int, int> m;
65+
int cnt = 0;
66+
for(int i: st) m[i] = cnt++;
67+
for(int i = 0; i < n; i++) a[i] = m[a[i]];
68+
vector <vector<int>> di(cnt);
69+
for(int i = 0; i < n; i++) di[a[i]].push_back(i);
70+
auto dfs = [&](auto & dfs, int u, int r, bool lead)->ll{
71+
if(u >= n) return 1;
72+
ll ans = 0; //对应两种选择,变成与之前的相同的或者+1
73+
for(int i = u; i <= r; i++){
74+
r = max(r, di[a[i]].back());
75+
}
76+
if(lead) ans = dfs(dfs, r + 1, r + 1, 0) % mod;
77+
else ans = 2 * dfs(dfs, r + 1, r + 1, 0) % mod;
78+
return ans % mod;
79+
};
80+
cout << dfs(dfs, 0, di[a[0]].back(), 1) % mod;
81+
}
82+
```
83+
84+

codeforces/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,84 @@
1+
# tags🏷
2+
3+
## Graph
4+
5+
- **最短路算法**
6+
7+
- 单源最短路
8+
9+
1. Dijkstra:O(n^2) or O(mlogn)
10+
11+
2. 0-1BFS:O(n)
12+
13+
3. Bellmon-Ford
14+
15+
4. SPFA
16+
17+
- 多源最短路
18+
19+
1. 多源BFS
20+
21+
2. Floyd算法
22+
23+
- **最小生成树算法**
24+
25+
- Prim算法
26+
27+
- Kruskal算法
28+
29+
- **图的匹配**
30+
31+
- 匈牙利算法
32+
33+
- Km算法
34+
35+
- 染色法判定二分图
36+
37+
- **拓扑排序**
38+
39+
- 队列实现的拓扑排序
40+
41+
## Dynamic Programming
42+
43+
- **线性DP**
44+
45+
- **背包DP**
46+
47+
- **区间DP**
48+
49+
- **状态机DP**
50+
51+
- **记忆化搜索**
52+
53+
- **数位DP**
54+
55+
- **计数DP**
56+
57+
- **树形DP**
58+
59+
## Binary Search
60+
61+
- 二分 + 贪心
62+
63+
- 二分 + 前缀和
64+
65+
- 二分 + BFS
66+
67+
## **Math**
68+
69+
- 欧拉函数
70+
71+
- gcd
72+
73+
-
74+
75+
## Greedy
76+
77+
### Simulation
78+
79+
- 基本计算器(支持扩展运算)
80+
81+
-
182

283
## constructive algorithms
384

codeforces/constructive_algorithms/1630A.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@
77
- 当且仅当n = 4, k = 3的时候,用枚举的方法容易发现这是无法构造出来的
88

99
接着思考,在什么情况下可能会出现无解?
10-
11-

0 commit comments

Comments
 (0)