-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.xml
More file actions
493 lines (236 loc) · 280 KB
/
atom.xml
File metadata and controls
493 lines (236 loc) · 280 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Fighting</title>
<subtitle>少年,冲冲冲!</subtitle>
<link href="https://lzl2040.github.io/atom.xml" rel="self"/>
<link href="https://lzl2040.github.io/"/>
<updated>2023-04-01T04:00:37.292Z</updated>
<id>https://lzl2040.github.io/</id>
<author>
<name>Yxmlzl</name>
</author>
<generator uri="https://hexo.io/">Hexo</generator>
<entry>
<title>论文阅读-CLIP4Clip An Empirical Study of CLIP for End to End Video Clip Retrieval</title>
<link href="https://lzl2040.github.io/2022/10/15/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-CLIP4Clip-An-Empirical-Study-of-CLIP-for-End-to-End-Video-Clip-Retrieval/"/>
<id>https://lzl2040.github.io/2022/10/15/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-CLIP4Clip-An-Empirical-Study-of-CLIP-for-End-to-End-Video-Clip-Retrieval/</id>
<published>2022-10-15T01:05:11.000Z</published>
<updated>2023-04-01T04:00:37.292Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-CLIP4Clip-An-Empirical-Study-of-CLIP-for-End-to-End-Video-Clip-Retrieval"><a href="#论文阅读-CLIP4Clip-An-Empirical-Study-of-CLIP-for-End-to-End-Video-Clip-Retrieval" class="headerlink" title="论文阅读-CLIP4Clip: An Empirical Study of CLIP for End to End Video Clip Retrieval"></a>论文阅读-CLIP4Clip: An Empirical Study of CLIP for End to End Video Clip Retrieval</h1><p>Code:<a href="https://github/">https://github</a>. com/ArrowLuo/CLIP4Clip.</p><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>视频文本检索在多模态研究中起着至关重要的作用,并已广泛用于许多现实世界的 Web 应用程序中。 CLIP(对比语言-图像预训练)是一种图像语言预训练模型,它展示了从网络收集的图像-文本数据集中学习视觉概念的能力。在本文中,我们提出了一个 CLIP4Clip 模型,以端到端的方式将 CLIP 模型的知识转移到视频语言检索中。通过实证研究调查了几个问题:(1)图像特征是否足以用于视频文本检索?(2)基于 CLIP 的大规模视频文本数据集的后预训练如何影响性能?(3)模拟视频帧之间的时间依赖性的实际机制是什么?(4)模型对视频文本检索任务的超参数敏感性。大量实验结果表明,从 CLIP 转换而来的 CLIP4Clip 模型可以在各种视频文本检索数据集上取得 SOTA 结果,包括 MSR-VTT、MSVC、LSMDC、ActivityNet 和 DiDeMo。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Existing-Problems"><a href="#Existing-Problems" class="headerlink" title="Existing Problems"></a>Existing Problems</h3><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><p>(1)we investigate three mechanisms of similarity calculation based on the pretrained CLIP</p><p>(2)we further post pre-train the CLIP on a noisy large-scale video-language dataset to learn a better retrieval space.</p><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>(1)Video Encoder Backbone</p><p>(2)Visual Representation Learning from Text Supervision</p><p>(3)Video-Text Retrieval</p><h2 id="Framework"><a href="#Framework" class="headerlink" title="Framework"></a>Framework</h2><h3 id="Task-Defination"><a href="#Task-Defination" class="headerlink" title="Task Defination"></a>Task Defination</h3><p>Given a set of videos (or video clips) V and a set of captions T , our target is to learn a function s(vi, tj) to calculate the similarity between the video (or video clip) vi ∈ V and the caption tj ∈ T .</p><p>The goal is to rank all the videos (or video clips) given the query caption according to their similarity score in the text-to-video retrieval or rank all the captions given the query video (or video clip) in the task of video-to-text retrieval.</p><p>The objective of the s(vi, tj) is to calculate a high similarity for relevant videotext pairs and a low similarity score for irrelevant ones. s(vi, tj) 的目标是计算相关视频文本对的高相似度和不相关视频文本对的低相似度分数。</p><h3 id="Video-Encoder"><a href="#Video-Encoder" class="headerlink" title="Video Encoder"></a>Video Encoder</h3><p><strong>Backnone</strong> :CLIP (ViT-B/32)</p><p><strong>Input</strong> :input frame sequence of video vi = {vi^1^ , vi^2^ , . . . , vi^|vi|^ }</p><p><strong>Output</strong> :generated frame representation Zi = {zi^1^, zi^2^, . . . , zi^|vi|^}.</p><p><strong>Process</strong> :(1)extracts non-overlapping image patches</p><p>(2)performs a linear projection to project them into 1D tokens</p><p>(3)exploits the transformer architecture to model the interaction between each patch of the input image to get the final representation</p><p><strong>Two types of linear projections</strong> :2D linear and 3D linear</p><h3 id="Text-Encoder"><a href="#Text-Encoder" class="headerlink" title="Text Encoder"></a>Text Encoder</h3><p>It applies the text encoder from the CLIP</p><p>Output:the feature representation of the caption wj</p><h3 id="Similarity-Calculator"><a href="#Similarity-Calculator" class="headerlink" title="Similarity Calculator"></a>Similarity Calculator</h3><p>**Background **:It is hard to learn without weight initialization and may hurt the performance of the pre-trained model training with backpropagation.</p><p><strong>Category</strong> :(1)parameter-free approach (2)sequential type (3)tight type</p><p>(1) and (2) calculate cosine similarity.(3) uses the transformer model</p><h4 id="Parameter-free-type"><a href="#Parameter-free-type" class="headerlink" title="Parameter-free type"></a>Parameter-free type</h4><p>(1)uses the mean pooling to aggregate the feature of all frames to obtain an ‘average frame’ zi = mean-pooling(zi^1^, zi^2^, . . . , zi^|vi|^ ).</p><p>(2)cal cosine similarity</p><p><strong>Disadvantages</strong>:ignores the sequential information between frames.</p><h4 id="Sequential-type"><a href="#Sequential-type" class="headerlink" title="Sequential type"></a>Sequential type</h4><p>It uses two methods to model the sequential feature for Sequential type similarity calculator,including LSTM and Transformer encoder</p><p><strong>Process</strong>:</p><p>(1)Through the encoding which embeds the temporal information and is used seperately.</p><p>Z ̃i = LSTM(Zi) and Z ̃i = Transformer-Enc(Zi +P)</p><p>(2)uses the mean pooling</p><p>(3)cal cosine similarity</p><h4 id="Tight-type"><a href="#Tight-type" class="headerlink" title="Tight type"></a>Tight type</h4><p><strong>Process</strong>:</p><p>(1)concatenate caption representation wj and frames’ representation Zi</p><p>(2)through the Transformer Encoder</p><p>explanation:P is the position embedding, and T is type embedding similar to Segment Embeddings in BERT.The T contains two types of embedding, one is for caption and the other is for video frames.</p><p>(3)calculate similarity score with two linear projection layers plus an activation upon the first token output of the last layer Ui ̃ [0, :].</p><h3 id="Training-Strategy"><a href="#Training-Strategy" class="headerlink" title="Training Strategy"></a>Training Strategy</h3><h4 id="Loss-Function"><a href="#Loss-Function" class="headerlink" title="Loss Function"></a>Loss Function</h4><p>use a symmetric cross entropy loss</p><h4 id="Frame-Sampling"><a href="#Frame-Sampling" class="headerlink" title="Frame Sampling"></a>Frame Sampling</h4><p>It adopts a uniform frame sampling strategy.The sampling rate is 1 frame per second</p><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>在本文中,我们使用预训练的 CLIP 作为我们的主干来解决帧级输入的视频剪辑检索任务。我们采用无参数类型、顺序类型和紧密类型相似度计算器来获得最终结果。实验结果证明了我们模型的有效性,并在 MSR-VTT、MSVC、LSMDC、ActivityNet 和 DiDeMo 上实现了 SOTA 结果。此外,我们从实证研究中提供了一些见解:(1)图像特征也可以促进视文检索;(2)在甚至出色的图像文本上进行预训练后预训练的 CLIP 可以进一步提高视频文本检索的性能(3)3D patch线性投影和序列类型相似性是检索任务的有前途的方法(4)用于视频文本检索的 CLIP 是学习率敏感性。</p>]]></content>
<summary type="html"><h1 id="论文阅读-CLIP4Clip-An-Empirical-Study-of-CLIP-for-End-to-End-Video-Clip-Retrieval"><a href="#论文阅读-CLIP4Clip-An-Empirical-Study-of-CLIP-f</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2021" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2021/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="多模态" scheme="https://lzl2040.github.io/tags/%E5%A4%9A%E6%A8%A1%E6%80%81/"/>
</entry>
<entry>
<title>论文阅读-Graph-Based Global Reasoning Networks</title>
<link href="https://lzl2040.github.io/2022/10/13/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Graph-Based-Global-Reasoning-Networks/"/>
<id>https://lzl2040.github.io/2022/10/13/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Graph-Based-Global-Reasoning-Networks/</id>
<published>2022-10-13T07:35:08.000Z</published>
<updated>2023-04-01T04:00:29.061Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Graph-Based-Global-Reasoning-Networks"><a href="#论文阅读-Graph-Based-Global-Reasoning-Networks" class="headerlink" title="论文阅读-Graph-Based Global Reasoning Networks"></a>论文阅读-Graph-Based Global Reasoning Networks</h1><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>对区域之间的关系进行全局建模和推理对于图像和视频上的许多计算机视觉任务都是有益的。卷积神经网络 (CNN) 擅长通过卷积操作对局部关系进行建模,但它们通常在捕获远距离区域之间的全局关系方面效率低下,并且需要堆叠多个卷积层。在这项工作中,我们提出了一种全局推理的新方法,其中一组特征在坐标空间上全局聚合,然后投影到可以有效计算关系推理的交互空间。经过推理,关系感知特征被分配回原始坐标空间用于下游任务。我们进一步展示了所提出方法的高效实例化,并介绍了全局推理单元(GloRe 单元),该单元通过加权全局池化和加权广播实现坐标交互空间映射,以及通过交互中的小图上的图卷积实现关系推理 空间。提议的 GloRe 单元是轻量级的、端到端可训练的,并且可以轻松插入现有的 CNN 以执行各种任务。大量实验表明,我们的 GloRe 单元可以持续提升最先进的骨干架构的性能,包括 ResNet 、ResNeXt 、SE-Net 和 DPN ,对于 2D 和 3D CNN,用于图像分类、语义分割和视频动作识别任务。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Existing-Problem"><a href="#Existing-Problem" class="headerlink" title="Existing Problem"></a>Existing Problem</h3><p>Deep CNNs cannot capture the relations from different regions of an image/video without stacking multiple convolution layers, since an individual layer can only capture information locally</p><h3 id="Our-Solution"><a href="#Our-Solution" class="headerlink" title="Our Solution"></a>Our Solution</h3><p>We propose a unit to directly perform global relation reasoning by projecting features from regions of interest to an interaction space and then distribute back to the original coordinate space.</p><h3 id="Our-Advantages"><a href="#Our-Advantages" class="headerlink" title="Our Advantages"></a>Our Advantages</h3><p>(1)Our proposed model is able to directly reason on relations over regions</p><p>(2)It is not designed for regional reasoning(不是很理解)</p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><p>(1)We propose a new approach for reasoning globally by projecting a set of features that are globally aggregated over the coordinate space into an interaction space where relational reasoning can be efficiently computed</p><p>(2)We present the Global Reasoning unit (GloRe unit) a highly efficient instantiation of the proposed approach that implements the coordinate-interaction space mapping by weighted global pooling and weighted broadcasting, and the relation reasoning via graph convolution in the interaction space.</p><p>(3)We conduct extensive experiments on a number of datasets and show the Global Reasoning unit can bring consistent performance boost for a wide range of backbones including ResNet, ResNeXt, SE-Net and DPN, for both 2D and 3D CNNs, on image classification, semantic segmentation and video action recognition task.</p><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>(1)Deep Architecture Design.</p><p>(2)Global Context Modeling</p><p>(3)Graph-based Reasoning</p><h2 id="Graph-based-Global-Reasoning"><a href="#Graph-based-Global-Reasoning" class="headerlink" title="Graph-based Global Reasoning"></a>Graph-based Global Reasoning</h2><h3 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h3><p>Motivation:overcome the intrinsic limitation of convolution operations for modeling global relations.</p><p>Global Reasoning unit:</p><h3 id="From-Coordinate-Space-to-Interaction-Space"><a href="#From-Coordinate-Space-to-Interaction-Space" class="headerlink" title="From Coordinate Space to Interaction Space"></a>From Coordinate Space to Interaction Space</h3><p>maps original features to the interaction space H to get new features V:</p><h3 id="Reasoning-with-Graph-Convolution"><a href="#Reasoning-with-Graph-Convolution" class="headerlink" title="Reasoning with Graph Convolution"></a>Reasoning with Graph Convolution</h3><p>Defination:<strong>G and Ag</strong> denote the N × N node adjacency matrix for diffusing information across nodes</p><p><strong>Wg</strong> denote the state update function</p><p>(1)performs Laplacian smoothing, propagating the node features over the graph.</p><p>(2)The node’s state is updated through a linear transformation</p><h3 id="From-Interaction-Space-to-Coordinate-Space"><a href="#From-Interaction-Space-to-Coordinate-Space" class="headerlink" title="From Interaction Space to Coordinate Space"></a>From Interaction Space to Coordinate Space</h3><p>Task:Given the node-feature matrix Z ∈ N×C , we aim to learn a mapping function that can transform the features to Y ∈ L×C</p><p>We adopt linear projection to formulate g(Z)</p>]]></content>
<summary type="html"><h1 id="论文阅读-Graph-Based-Global-Reasoning-Networks"><a href="#论文阅读-Graph-Based-Global-Reasoning-Networks" class="headerlink" title="论文阅读-Gra</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2019" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2019/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="GNN" scheme="https://lzl2040.github.io/tags/GNN/"/>
</entry>
<entry>
<title>论文阅读笔记-GNN综述</title>
<link href="https://lzl2040.github.io/2022/10/07/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0-GNN%E7%BB%BC%E8%BF%B0/"/>
<id>https://lzl2040.github.io/2022/10/07/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0-GNN%E7%BB%BC%E8%BF%B0/</id>
<published>2022-10-07T05:06:27.000Z</published>
<updated>2022-10-07T16:04:17.631Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读笔记-GNN综述"><a href="#论文阅读笔记-GNN综述" class="headerlink" title="论文阅读笔记-GNN综述"></a>论文阅读笔记-GNN综述</h1><p>主要介绍了GNN以及它在各个领域的应用</p><h2 id="2D-NATURAL-IMAGES"><a href="#2D-NATURAL-IMAGES" class="headerlink" title="2D NATURAL IMAGES"></a>2D NATURAL IMAGES</h2><h3 id="Image-Classification"><a href="#Image-Classification" class="headerlink" title="Image Classification"></a>Image Classification</h3><h4 id="Multi-Label-Classification"><a href="#Multi-Label-Classification" class="headerlink" title="Multi-Label Classification"></a>Multi-Label Classification</h4><p><strong>ML-GCN</strong>:builds a directed graph on the basis of label space, where each node stands for a object label (word embeddings) and their connections model the inter-dependencies of different labels.</p><p><strong>attention-driven GCN</strong>:model the label dependencies via more elaborate GNN architectures</p><p><strong>hypergraph neural networks</strong>:model the label dependencies via more elaborate GNN architectures</p><h4 id="Few-Shot-Learning"><a href="#Few-Shot-Learning" class="headerlink" title="Few-Shot Learning"></a>Few-Shot Learning</h4><table><thead><tr><th>论文名称</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Few-shot learning with graph neural networks</td><td>ICLR,2018</td><td>formulate FSL as a supervised interpolation problem on a densely-connected graph, where the vertices stand for images in the collection and the adjacency is learnable with trainable similarity kernels.</td></tr><tr><td>Learning to propagate labels: Transductive propagation network for few-shot learning</td><td>ICLR,2019</td><td>constructs graphs on the top of embedding space to fully exploit the manifold structure of the novel classes.Label information is propagated from the support set to the query set based on the constructed graphs</td></tr><tr><td>dge-labeling graph neural network for few-shot learning</td><td>CVPR,2019</td><td>propose a edge-labeling GNN framework that learns to predict edge labels, explicitly constraining the intra- and inter-class similarities.</td></tr><tr><td>Learning from the past: Continual meta-learning via bayesian graph modeling</td><td>AAAI,2020</td><td>formulate meta-learning-based FSL as continual learning of a sequence of tasks and resort to Bayesian GNN to capture the intra- and inter-task correlations.</td></tr><tr><td>Dpgn: Distribution propagation graph network for few-shot learning</td><td>CVPR,2020</td><td>devise a dual complete graph network to model both distribution- and instance-level relations.</td></tr><tr><td>Hierarchical graph neural networks for few-shot learning</td><td>TCSVT,2021</td><td>exploit the hierarchical relationships among graph nodes via the bottom-up and top-down reasoning modules.</td></tr><tr><td>Hybrid graph neural networks for few-shot learning</td><td>AAAI,2022</td><td>introduce an instance GNN and a prototype GNN as feature embedding task adaptation modules for quickly adapting learned features to new tasks.</td></tr></tbody></table><h4 id="Zero-Shot-Learning-ZSL"><a href="#Zero-Shot-Learning-ZSL" class="headerlink" title="Zero-Shot Learning (ZSL)"></a>Zero-Shot Learning (ZSL)</h4><table><thead><tr><th>论文名称</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Rethinking knowledge graph propagation for zero-shot learning</td><td>CVPR,2019</td><td>propose a Dense Graph Propagation (DGP) module to exploit the hierarchical structure of knowledge graph.It consists of two phases to iteratively propagate knowledge between a node and its ancestors and descendants.</td></tr><tr><td>Region graph embedding network for zero-shot learning</td><td>ECCV,2020</td><td>represent each input image as a region graph, where each node stands for an attended region in the image and the edges are appearance similarities among these region nodes.</td></tr><tr><td>Attribute propagation network for graph zero-shot learning</td><td>AAAI,2020</td><td>generates and updates attribute vectors with an attribute propagation network for optimizing the attribute space</td></tr><tr><td>Isometric propagation network for generalized zero-shot learning</td><td>ICLR,2021</td><td>introduce the visual and semantic prototype propagation on auto-generated graphs to enhance the inter-class relations and align the corresponding classwise dependencies in visual and semantic space</td></tr><tr><td>Learning graph embeddings for open world compositional zero-shot learning</td><td>TPAMI, 2022</td><td>introducing a Compositional Cosine Graph Embedding (Co-CGE) model to learn the relationship between primitives and compositions through a GCN.They quantitatively measure the feasibility scores of a state-object composition and incorporate the computed scores into CoCGE in two ways</td></tr><tr><td>Gndan: Graph navigated dual attention network for zero-shot learning</td><td>IEEE TNNLS, 2022</td><td>resort to GAT for exploiting the appearance relations between local regions and the cooperation between local and global features.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table><h4 id="Transfer-Learning"><a href="#Transfer-Learning" class="headerlink" title="Transfer Learning"></a>Transfer Learning</h4><table><thead><tr><th>论文名称</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Gcan: Graph convolutional adversarial network for unsupervised domain adaptation</td><td>CVPR,2019</td><td>propose a Graph Convolutional Adversarial Network (GCAN) for DA, where a GCN is developed on top of densely-connected instance graphs to encode data structure information.</td></tr><tr><td>Heterogeneous graph attention network for unsupervised multiple-target domain adaptation</td><td>IEEE TPAMI, 2020</td><td>build a heterogeneous relation graph and introduce GAT to propagate the semantic information and generate reliable pseudo-labels.</td></tr><tr><td>Curriculum graph co-teaching for multi-target domain adaptation</td><td>CVPR,2021</td><td>introduce a GCN to aggregate information from different domains along with a co-teaching and curriculum learning strategy to achieve progressive adaptation.</td></tr><tr><td>Progressive graph learning for open-set domain adaptation</td><td>ICML,2020</td><td>study the problem of open-set DA via a progressive graph learning framework to select pseudo-labels and thus avoid the negative transfer.</td></tr><tr><td>Prototype-matching graph network for heterogeneous domain adaptation</td><td>ACMMM 2020</td><td>attain cross-domain prototype alignment based on features learned from different stages of GNNs.</td></tr><tr><td>Learning to combine: Knowledge aggregation for multi-source domain adaptation</td><td>ECCV. Springer, 2020.</td><td>introduce a knowledge graph based on the prototypes of different domains to perform information propagation among semantically adjacent representations.</td></tr><tr><td>Compound domain generalization via meta-knowledge encoding</td><td>CVPR,2022</td><td>build global prototypical relation graphs and introduce a graph self-attention mechanism</td></tr></tbody></table><h4 id="当前工作重点"><a href="#当前工作重点" class="headerlink" title="当前工作重点"></a>当前工作重点</h4><p>Current work focuses on extracting adhoc knowledge graphs from the data for a certain task, which is heuristic and relies on the human prior</p><h4 id="未来的方向"><a href="#未来的方向" class="headerlink" title="未来的方向"></a>未来的方向</h4><p>(1)develop general and automatic graph construction procedures,</p><p>(2)enhance the interactions between abstract graph structures and task-specific classifiers</p><p>(3)excavate more fine-grained building blocks (node and edge) to increase the capability of constructed graphs.</p><h3 id="Object-Detection"><a href="#Object-Detection" class="headerlink" title="Object Detection"></a>Object Detection</h3><table><thead><tr><th>论文名称</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Reasoning-rcnn: Unifying adaptive global reasoning into large-scale object detection</td><td>CVPR,2019</td><td>presents an adaptive global reasoning network for large-scale object detection by incorporating commonsense knowledge (category-wise knowledge graph) and propagating visual information globally</td></tr><tr><td>Spatial-aware graph relation network for large-scale object detection</td><td>CVPR,2019</td><td>adaptively discover semantic and spatial relationships without requiring prior handcrafted linguistic knowledge</td></tr><tr><td>Relation networks for object detection</td><td>CVPR,2018</td><td>introduces an adapted attention module to detection head networks, explicitly learning information between objects through encoding the longrange dependencies.</td></tr><tr><td>Relationnet++: Bridging visual representations for object detection via transformer decoder</td><td>NeurIPS,2020</td><td>presents a selfattention-based decoder module to embrace the strengths of different object/part representations within a single detection framework.</td></tr><tr><td>Gar: Graph assisted reasoning for object detection</td><td>WACV,2020</td><td>introduce a heterogeneous graph to jointly model object-object and object-scene relations.</td></tr><tr><td>Graphfpn: Graph feature pyramid network for object detection</td><td>ICCV,2021</td><td>propose a graph feature pyramid network (GraphFPN), which explores the contextual and hierarchical structures of an input image based on a superpixel hierarchy</td></tr><tr><td>Relation matters: Foreground-aware graph-based relational reasoning for domain adaptive object detection</td><td>IEEE TPAMI,2022</td><td>first builds intra- and inter-domain relation graphs in virtue of cyclic between-domain consistency without any prior knowledge about the target distribution.</td></tr><tr><td>Sigma: Semantic-complete graph matching for domain adaptive object detection</td><td>ICCV,2021</td><td>formulates DAOD as a graph matching problem by establishing cross-image graphs to model classconditional distributions on both domains</td></tr><tr><td>Semantic relation reasoning for shot-stable few-shot object detection</td><td>CVPR,2022</td><td>introduces a semantic relation reasoning module to integrate semantic information between base and novel classes for novel object detection</td></tr></tbody></table><p>说明:domain adaptive object detection (DAOD)</p><h4 id="当前的工作重点"><a href="#当前的工作重点" class="headerlink" title="当前的工作重点"></a>当前的工作重点</h4><p>exploit between-object, cross-scale or cross-domain relationships, as well as relationships between base and novel classes</p><h4 id="未来的方向-1"><a href="#未来的方向-1" class="headerlink" title="未来的方向"></a>未来的方向</h4><p>(1)design better region-to-node feature mapping methods,</p><p>(2)incorporate Transformer (or pure GNN) encoders to improve the expressive power of initial node features</p><p>(3)directly perform reasoning in the original feature space to better preserve the intrinsic structure of images.</p><h3 id="Image-Segmentation"><a href="#Image-Segmentation" class="headerlink" title="Image Segmentation"></a>Image Segmentation</h3><h4 id="一般的分割"><a href="#一般的分割" class="headerlink" title="一般的分割"></a>一般的分割</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Dual graph convolutional network for semantic segmentation</td><td>BMVC,2019</td><td>targets on modeling the global context of input features via a dual GCN framework where a coordinate space GCN models spatial relationships between pixels in the image, and a feature space GCN models dependencies along the channel dimensions of the network’s feature map.</td></tr><tr><td>Graph-based global reasoning networks</td><td>CVPR,2019</td><td>design the global reasoning unit by projecting features that are globally aggregated in coordinate space to node domain and performing relational reasoning in a fullyconnected graph.</td></tr><tr><td>Dynamic graph message passing networks</td><td>CVPR,2020</td><td>dynamically samples the neighborhood of a node and then predicts the node dependencies, filter weights, and affinity matrix to attain information propagation</td></tr><tr><td>Representative graph neural network</td><td>ECCV,2020</td><td>propose to dynamically sample some representative nodes for relational modeling.</td></tr><tr><td>Spatial pyramid based graph reasoning for semantic segmentation</td><td>CVPR,2020</td><td>propose an improved Laplacian formulation that enables graph reasoning in the original feature space, fully exploiting the contextual relations at different feature scales.</td></tr><tr><td>Class-wise dynamic graph convolution for semantic segmentation</td><td>ECCV,2020</td><td>introduce a classwise dynamic graph convolution module to conduct graph reasoning over the pixels that belong to the same class</td></tr><tr><td>Bidirectional graph reasoning network for panoptic segmentation</td><td>CVPR,2020</td><td>design a bidirectional graph reasoning network to bridge the things branch and the stuff branch for panoptic segmentation.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table><h4 id="One-Shot-Semantic-Segmentation"><a href="#One-Shot-Semantic-Segmentation" class="headerlink" title="One-Shot Semantic Segmentation"></a>One-Shot Semantic Segmentation</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Pyramid graph networks with connection attentions for region-based oneshot semantic segmentation</td><td>ICCV,2019</td><td>introduce a pyramid graph attention module to model the connection between query and support feature maps</td></tr></tbody></table><h4 id="Few-Shot-Semantic-Segmentation"><a href="#Few-Shot-Semantic-Segmentation" class="headerlink" title="Few-Shot Semantic Segmentation"></a>Few-Shot Semantic Segmentation</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Scale-aware graph neural network for few-shot semantic segmentation</td><td>CVPR,2021</td><td>propose a scale-aware GNN to perform crossscale relational reasoning among support-query images. A self-node collaboration mechanism is introduced to perceive different resolutions of the same object.</td></tr></tbody></table><h4 id="Weakly-Supervised-Semantic-Segmentation"><a href="#Weakly-Supervised-Semantic-Segmentation" class="headerlink" title="Weakly Supervised Semantic Segmentation"></a>Weakly Supervised Semantic Segmentation</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Affinity attention graph neural network for weakly supervised semantic segmentation</td><td>IEEE,TPAMI 2021</td><td>an image will first be converted to a weighted graph via an affinity CNN network, and then an affinity attention layer is devised to obtain long-range interactions from the constructed graph and propagate semantic information to the unlabeled pixels</td></tr></tbody></table><h4 id="当前的工作重点-1"><a href="#当前的工作重点-1" class="headerlink" title="当前的工作重点"></a>当前的工作重点</h4><p>explore contextual information in the localor global-level with pyramid pooling, dilated convolutions, or the self-attention mechanism</p><h3 id="Scene-Graph-Generation-SGG"><a href="#Scene-Graph-Generation-SGG" class="headerlink" title="Scene Graph Generation (SGG)"></a>Scene Graph Generation (SGG)</h3><p>任务概述:检测图像中的对象对及其关系以生成可视化的场景图的任务,它提供了对视觉场景的高级理解,而不是孤立地处理单个对象</p><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td>Factorizable net: an efficient subgraph-based framework for scene graph generation</td><td>ECCV,2018</td><td>a subgraph-based approach (each subgraph is regarded as a node), has a spatially weighted message passing structure to refine the features of objects and subgroups by passing messages among them with attention-like schemes</td></tr><tr><td>Graph r-cnn for scene graph generation</td><td>ECCV,2018</td><td>first obtain a sparse candidate graph by pruning the densely-connected graph generated from RPN via a relation proposal network, then an attentional GCN is introduced to aggregate contextual information and update node features and edge relationships</td></tr><tr><td>Attentive relational networks for mapping images to scene graphs</td><td>CVPR,2019</td><td>propose attentive relational networks, which first transform label word embeddings and visual features into a shared semantic space, and then rely on GAT to perform feature aggregation for final relation inference</td></tr><tr><td>Bipartite graph network with adaptive message passing for unbiased scene graph generation</td><td>CVPR,2021</td><td>introduce bipartite GNN to estimate and propagate relation confidence in a multi-stage manner.</td></tr><tr><td>Energy-based learning for scene graph generation</td><td>CVPR,2021</td><td>propose an energybased framework, which depends on graph message passing algorithm for computing the energy of configurations.</td></tr></tbody></table><h2 id="VIDEO-UNDERSTANDING"><a href="#VIDEO-UNDERSTANDING" class="headerlink" title="VIDEO UNDERSTANDING"></a>VIDEO UNDERSTANDING</h2><h3 id="Video-Action-Recognition"><a href="#Video-Action-Recognition" class="headerlink" title="Video Action Recognition"></a>Video Action Recognition</h3><p>任务介绍:视频人体动作识别是视频处理和理解的基本任务之一,其目的是识别和分类RGB/深度视频或骨架数据中的人体动作。</p><h4 id="Action-Recognition"><a href="#Action-Recognition" class="headerlink" title="Action Recognition"></a>Action Recognition</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td></td><td></td><td>propose to capture the long-range temporal contexts via graph-based reasoning over human-object and object-object relationships</td></tr><tr><td></td><td></td><td>construct actor-centric object-level graph and applying GCNs to capture the contexts among objects in a actor-centric way.A relation-level graph is built to inference the contexts in relation nodes</td></tr><tr><td></td><td></td><td>propose multi-scale reasoning in the temporal graph of a video, in which each node is a frame in the video, and the pairwise relations between nodes are represented as a learnable adjacent matrix</td></tr><tr><td></td><td></td><td>extend the GCN-based relation modeling to zero-shot action recognition and leverage knowledge graphs to model the relations among actions and attributes jointly</td></tr><tr><td></td><td></td><td>introduce a graph-based high-order relation modeling method for long-term action recognition.</td></tr></tbody></table><h4 id="Skeleton-Based-Action-Recognition"><a href="#Skeleton-Based-Action-Recognition" class="headerlink" title="Skeleton-Based Action Recognition."></a>Skeleton-Based Action Recognition.</h4><table><thead><tr><th>论文题目</th><th>来源</th><th>主要思想</th></tr></thead><tbody><tr><td></td><td></td><td>propose a STGCN network first connects joints in a frame according to the natural connectivity in the human body and then connects the same joints in two consecutive frames to maintain temporal information.</td></tr><tr><td></td><td></td><td>introduce a fully-connected graph with learnable edge weights between joints and a data-dependent graph learned from the input skeleton.</td></tr><tr><td></td><td></td><td>connect physically-apart skeleton joints to captures the patterns of collaborative moving joints</td></tr><tr><td></td><td></td><td>improves the joints’ connection in a single frame by adding edges between limbs and head.it uses GCNs to capture joints’ relations in single frames and adopt the LSTM to capture the temporal dynamics.</td></tr><tr><td></td><td></td><td>introduce to maintain edge features and learn both node and edge feature representations via directed graph convolution.</td></tr><tr><td></td><td></td><td>first construct multiple dilated windows over temporal dimension.Then separately utilize GCNs on multiple graphs with different scales.Finally aggregate the results of GCNs on all the graphs in multiple windows to capture multi-scale and long-range dependencies.</td></tr></tbody></table><h3 id="Temporal-Action-Localization"><a href="#Temporal-Action-Localization" class="headerlink" title="Temporal Action Localization"></a>Temporal Action Localization</h3>]]></content>
<summary type="html"><h1 id="论文阅读笔记-GNN综述"><a href="#论文阅读笔记-GNN综述" class="headerlink" title="论文阅读笔记-GNN综述"></a>论文阅读笔记-GNN综述</h1><p>主要介绍了GNN以及它在各个领域的应用</p>
<h2 id</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="GNN" scheme="https://lzl2040.github.io/tags/GNN/"/>
</entry>
<entry>
<title>论文阅读-Masked Autoencoders Are Scalable Vision Learners</title>
<link href="https://lzl2040.github.io/2022/09/28/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Masked-Autoencoders-Are-Scalable-Vision-Learners/"/>
<id>https://lzl2040.github.io/2022/09/28/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Masked-Autoencoders-Are-Scalable-Vision-Learners/</id>
<published>2022-09-28T08:23:33.000Z</published>
<updated>2022-10-08T10:07:51.395Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Masked-Autoencoders-Are-Scalable-Vision-Learners"><a href="#论文阅读-Masked-Autoencoders-Are-Scalable-Vision-Learners" class="headerlink" title="论文阅读-Masked Autoencoders Are Scalable Vision Learners"></a>论文阅读-Masked Autoencoders Are Scalable Vision Learners</h1><h2 id="摘要"><a href="#摘要" class="headerlink" title="摘要"></a>摘要</h2><p>本文表明,掩码自编码器 (MAE) 是用于计算机视觉的可扩展自监督学习器。我们的 MAE 方法很简单:我们屏蔽输入图像的随机patch并重建丢失的像素。它基于两个核心设计。首先,我们开发了一个非对称的编码器-解码器架构,其中一个编码器只对可见的patch子集(没有掩码token)进行操作,以及一个轻量级解码器,它从潜在表示和掩码token重建原始图像。其次,我们发现屏蔽输入图像的高比例,例如 75%,会产生一个重要且有意义的自我监督任务。结合这两种设计使我们能够有效地训练大型模型:我们加速训练(3 倍或更多)并提高准确性。我们的可扩展方法允许学习具有良好泛化能力的大容量模型:例如,vanilla ViT-Huge 模型在仅使用 ImageNet-1K 数据的方法中实现了最佳准确度 (87.8%)。下游任务中的迁移性能优于有监督的预训练,并显示出有希望的扩展行为。</p><h2 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h2><h3 id="The-idea-of-masked-autoencoders"><a href="#The-idea-of-masked-autoencoders" class="headerlink" title="The idea of masked autoencoders"></a>The idea of masked autoencoders</h3><p>they remove a portion of the data and learn to predict the removed content.</p><h3 id="what-makes-masked-autoencoding-different-between-vision-and-language"><a href="#what-makes-masked-autoencoding-different-between-vision-and-language" class="headerlink" title="what makes masked autoencoding different between vision and language?"></a>what makes masked autoencoding different between vision and language?</h3><p>(1)Convolutions typically operate on regular grids and it is not straightforward to integrate ‘indicators’ such as mask tokens or positional embeddings into convolutional networks.卷积通常在规则网格上运行,将诸如掩码标记或位置嵌入 之类的“指标”集成到卷积网络中并不简单。</p><p>(2)Information density is different between language and vision.Languages are human-generated signals that are highly semantic and information-dense.Images are natural signals with heavy spatial redundancy</p><p>(3)The autoencoder’s decoder, which maps the latent representation back to the input, plays a different role between reconstructing text and images</p><h2 id="相关工作"><a href="#相关工作" class="headerlink" title="相关工作"></a>相关工作</h2><h3 id="Masked-language-modeling"><a href="#Masked-language-modeling" class="headerlink" title="Masked language modeling"></a>Masked language modeling</h3><p>代表性工作:BERT与GPT</p><h3 id="Autoencoding"><a href="#Autoencoding" class="headerlink" title="Autoencoding"></a>Autoencoding</h3><p>组成:It has an encoder that maps an input to a latent representation and a decoder that reconstructs the input.</p><p>代表性作品:PCA,k-means,Denoising autoencoders (DAE)</p><p>DAE:corrupt an input signal and learn to reconstruct the original, uncorrupted signal.</p><h3 id="Masked-image-encoding"><a href="#Masked-image-encoding" class="headerlink" title="Masked image encoding"></a>Masked image encoding</h3><h3 id="Self-supervised-learning"><a href="#Self-supervised-learning" class="headerlink" title="Self-supervised learning"></a>Self-supervised learning</h3><h2 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h2><h3 id="Masking"><a href="#Masking" class="headerlink" title="Masking"></a>Masking</h3><p>First,we divide an image into regular non-overlapping patches.</p><p>Second,we sample a subset of patches and mask (i.e., remove) the remaining ones</p><p><strong>sampling strategy</strong>:we sample random patches without replacement, following a uniform distribution.</p><h3 id="MAE-encoder"><a href="#MAE-encoder" class="headerlink" title="MAE encoder"></a>MAE encoder</h3><p>组成:ViT,but applied only on visible, unmasked patches</p><p>注意:Our encoder only operates on a small subset (e.g., 25%) of the full set</p><h3 id="MAE-decoder"><a href="#MAE-decoder" class="headerlink" title="MAE decoder"></a>MAE decoder</h3><p>输入:the full set of tokens consisting of (i) encoded visible patches, and (ii) mask tokens.And we add positional embeddings to all tokens in this full set</p><p>注意:it is only used during pre-training to perform the image reconstruction task</p><p>不对称的设计:We experiment with very small decoders, narrower and shallower than the encoder</p><p>不对称设计的优点:the full set of tokens are only processed by the lightweight decoder, which significantly reduces pre-training time.</p><h3 id="Reconstruction-target"><a href="#Reconstruction-target" class="headerlink" title="Reconstruction target"></a>Reconstruction target</h3><p>输出:The last layer of the decoder is a linear projection whose number of output channels equals the number of pixel values in a patch,whose output is reshaped to form a reconstructed image.</p><p>损失函数:computes the <strong>mean squared error (MSE)</strong> between the reconstructed and original images in the pixel space</p><h3 id="Simple-implementation"><a href="#Simple-implementation" class="headerlink" title="Simple implementation."></a>Simple implementation.</h3><p>(1)generate a token for every input patch (by linear projection with an added positional embedding)</p><p>(2)randomly shuffle the list of tokens and remove the last portion of the list, based on the masking ratio.</p><p>(3)add the output of (2) to the encoder</p><p>(4)append a list of mask tokens to the list of encoded patches</p><p>(5)unshuffle this full list (inverting the random shuffle operation) to align all tokens with their targets.</p><p>(6)apply the decoder to the full list (with positional embeddings added).</p><h2 id="实验"><a href="#实验" class="headerlink" title="实验"></a>实验</h2><h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><p>我们注意到图像和语言是不同性质的信号,必须仔细处理这种差异。</p>]]></content>
<summary type="html"><h1 id="论文阅读-Masked-Autoencoders-Are-Scalable-Vision-Learners"><a href="#论文阅读-Masked-Autoencoders-Are-Scalable-Vision-Learners" class="heade</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
</entry>
<entry>
<title>论文阅读-Learning Position and Target Consistency for Memory-based Video Object Segmentation</title>
<link href="https://lzl2040.github.io/2022/09/22/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Learning%20Position%20and%20Target%20Consistency%20for%20Memory-based%20Video%20Object/"/>
<id>https://lzl2040.github.io/2022/09/22/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Learning%20Position%20and%20Target%20Consistency%20for%20Memory-based%20Video%20Object/</id>
<published>2022-09-22T08:35:28.000Z</published>
<updated>2022-09-23T02:14:40.059Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Learning-Position-and-Target-Consistency-for-Memory-based-Video-Object-Segmentation"><a href="#论文阅读-Learning-Position-and-Target-Consistency-for-Memory-based-Video-Object-Segmentation" class="headerlink" title="论文阅读-Learning Position and Target Consistency for Memory-based Video Object Segmentation"></a>论文阅读-Learning Position and Target Consistency for Memory-based Video Object Segmentation</h1><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>本文研究半监督视频对象分割(VOS)问题。多项工作表明,基于memory的方法可以有效地进行视频对象分割。它们主要基于像素级匹配,无论是空间上还是时间上。基于memory的方法的主要缺点是它们没有考虑帧之间的顺序,也没有利用来自目标的对象级知识。为了解决这个限制,我们提出学习基于内存的视频对象分割的Learn position and target Consistency框架,称为 LCM。它应用内存机制来全局检索像素,同时学习位置一致性以实现更可靠的分割。学习到的位置响应促进了目标和干扰物之间的更好区分。此外,LCM 引入了来自目标的对象级关系以保持目标一致性,使 LCM 对error drifting更加鲁棒。实验表明,我们的 LCM 在 DAVIS 和 Youtube-VOS 基准测试中都达到了最先进的性能。 我们在 DAVIS 2020 挑战半监督 VOS 任务中排名第一。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Existing-Problems"><a href="#Existing-Problems" class="headerlink" title="Existing Problems"></a>Existing Problems</h3><p>(1)Past memory-based methods may fail when a non-target region share similar visual appearance with the target regions</p><p>(2)Typical matching-based methods only consider pixel-level feature without the context information from the entire object.</p><h3 id="Solution"><a href="#Solution" class="headerlink" title="Solution"></a>Solution</h3><p>We propose a novel framework to Learn position and target Consistency for Memory-based video object segmentation(LCM),which includes Global Retrieval Module(GRM),Position Guidance Module(PGM) and Object Relation Module(ORM).</p><p>每个模块的作用:</p><p>(1)Global Retrieval Module(GRM):performs pixel-level matching mechanism to retrieve target pixels based on similarity and stores previous information in a memory pool.</p><p>(2)Position Guidance Module(PGM):fully utilize the position consistency and guides the segmentation by learning a location response</p><p>(3)Object Relation Module(ORM):maintain target consistency</p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><ul><li>We propose a novel Position Guidance Module to compute a location response to maintain position consistency in memory-based methods.</li><li>We propose Object Relation Module to effectively fuse object-level information for maintaining consistency of the target object.</li><li>We achieve state-of-the-art performance on both DAVIS and Youtube-VOS benchmark and rank the 1st in the DAVIS 2020 challenge semi-supervised VOS task</li></ul><h2 id="Related-Works"><a href="#Related-Works" class="headerlink" title="Related Works"></a>Related Works</h2><p>(1)Top-down methods for VOS</p><p>They first conduct detection methods to obtain proposals for target objects and then predict mask results.</p><p>(2)Propagation-based methods for VOS.</p><p>Propagationbased methods utilize the information from previous frames</p><p>(3)Matching-based methods for VOS.</p><p>Matching-based methods perform pixel-level matching between template frame and current frame.</p><p>(4)Attention mechanism.</p><h2 id="Methods"><a href="#Methods" class="headerlink" title="Methods"></a>Methods</h2><h3 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h3><img src="https://s1.ax1x.com/2022/09/23/xkKyPP.png" alt="network" style="zoom:67%;" /><h3 id="Global-Retrieval-Module"><a href="#Global-Retrieval-Module" class="headerlink" title="Global Retrieval Module"></a>Global Retrieval Module</h3><p><strong>the backbone of encoder</strong>:Resnet50</p><p><strong>defination</strong>:For the tth frame, the output feature maps are defined as <strong>r^M^ (H×W ×C) and r^Q^(H×W ×C)</strong></p><p><strong>calculation</strong>:</p><p>(1)compute the memory global key k^M^ (H×W ×C/8) and memory value v^M^ (H×W ×C/2):they are embedded through two separated 3×3 convolutional layers from <strong>rM</strong>.</p><p>(2)stored k^M^ and v^M^ in memory pool by concatenating them respectively along the temporal dimension.Finally we can get kMp(T ×H×W ×C/8) and vMp(T ×H×W ×C/2)</p><p>(3)compute the query global key k^Q^ (H×W ×C/8):it is embedded from rQ.</p><p>(4)compute the similarity of the global key between query and memory pool:</p><img src="https://s1.ax1x.com/2022/09/23/xkK4Vs.png" alt="f1" style="zoom:67%;" /><p>说明:<strong>i and j</strong> are the pixel feature indexes of memory pool and the query;represents the matrix inner production;<strong>function s</strong> denotes the sof tmax operation</p><p>(5)compute the retrieved value feature</p><img src="https://s1.ax1x.com/2022/09/23/xkKI5q.png" alt="f2" style="zoom:67%;" /><p>该模块不足之处:The calculation of the correlation map is equally conducted with all features in memory pool without position consistency.</p><h3 id="Position-Guidance-Module"><a href="#Position-Guidance-Module" class="headerlink" title="Position Guidance Module"></a>Position Guidance Module</h3><p>(1)compute the query local key <strong>kQL(H×W ×C/8)</strong> and memory local key <strong>kML(H×W ×C/8)</strong>:</p><ul><li>extract local key from the <strong>res4</strong> feature map</li><li>apply 3×3 convolutional layer for both query embedding and previous adjacent memory embedding</li></ul><p>(2)compute p<strong>M</strong> and p<strong>Q</strong> :</p><img src="https://s1.ax1x.com/2022/09/23/xkKWrQ.png" alt="f3" style="zoom:67%;" /><p>说明:<strong>pos(i)</strong>:sine and cosine functions with different frequencies</p><p><strong>fn</strong>:a 1×1 convolutional layer</p><p>(3)use the previous predicted mask to reduce the response of non-object areas</p><img src="https://s1.ax1x.com/2022/09/23/xkKfbj.png" alt="f4" style="zoom:67%;" /><p>说明:g(x) = exp(x)/e,作用:prevents the response from the location of background close to zero since the previous prediction is not always correct.</p><p>(4)conduct elementwise product between the position map and the query value <strong>vQ</strong></p><img src="https://s1.ax1x.com/2022/09/23/xkKRKg.png" style="zoom:67%;" /><p>the effectiveness of PGM:</p><img src="https://s1.ax1x.com/2022/09/23/xkQgBQ.png" alt="effective" style="zoom:67%;" /><p>整体的流程如下:</p><img src="https://s1.ax1x.com/2022/09/23/xkKDUI.png" alt="1" style="zoom:67%;" /><h3 id="Object-Relation-Module"><a href="#Object-Relation-Module" class="headerlink" title="Object Relation Module"></a>Object Relation Module</h3><p>针对的问题:The matching-based pixel retrieval is a bottom-up approach and lack of context information</p><p>(1)output respective <strong>non-local relation feature</strong></p><img src="https://s1.ax1x.com/2022/09/23/xkK5an.png" alt="f6" style="zoom:67%;" /><p>(2)compute y^ORM^</p><img src="https://s1.ax1x.com/2022/09/23/xkKTP0.png" alt="f7" style="zoom:67%;" /><p>整体的流程如下:</p><img src="https://s1.ax1x.com/2022/09/23/xkKr5t.png" alt="2" style="zoom:80%;" /><h3 id="Training-Strategy"><a href="#Training-Strategy" class="headerlink" title="Training Strategy"></a>Training Strategy</h3><p>(1)Pre-training on static images.</p><p>(2)Main-training on real videos without temporal limit.</p><p>(3)Fine-tuning on real videos as sequence</p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><p>Youtube-VOS 2018 validation dataset:</p><img src="https://s1.ax1x.com/2022/09/23/xkQD9P.png" alt="t1" style="zoom:67%;" /><p>DAVIS-2017 validation dataset</p><img src="https://s1.ax1x.com/2022/09/23/xkQ0ht.png" alt="t2" style="zoom:67%;" /><p>DAVIS-2017 test-dev dataset</p><img src="https://s1.ax1x.com/2022/09/23/xkQdAA.png" alt="t3" style="zoom:67%;" /><p>DAVIS-2016 validation dataset</p><img src="https://s1.ax1x.com/2022/09/23/xkQU7d.png" alt="t4" style="zoom:67%;" /><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>本文研究了基于内存的视频对象分割(VOS)问题,提出了基于内存的视频对象分割(LCM)的Learning position and target Consistency。我们遵循内存机制,引入全局检索模块(GRM)进行像素级匹配。此外,我们设计了位置指导模块(PGM)来学习位置一致性。我们将对象级信息与对象关系模块(ORM)集成。 我们的方法在 VOS 基准测试中实现了最先进的性能。</p>]]></content>
<summary type="html"><h1 id="论文阅读-Learning-Position-and-Target-Consistency-for-Memory-based-Video-Object-Segmentation"><a href="#论文阅读-Learning-Position-and-Targe</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2021" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2021/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="VOS" scheme="https://lzl2040.github.io/tags/VOS/"/>
</entry>
<entry>
<title>论文阅读-Efficient Regional Memory Network for Video Object Segmentation</title>
<link href="https://lzl2040.github.io/2022/09/21/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Efficient%20Regional%20Memory%20Network%20for%20Video%20Object%20Segmentation/"/>
<id>https://lzl2040.github.io/2022/09/21/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Efficient%20Regional%20Memory%20Network%20for%20Video%20Object%20Segmentation/</id>
<published>2022-09-21T04:30:50.000Z</published>
<updated>2022-09-22T02:09:30.838Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Efficient-Regional-Memory-Network-for-Video-Object-Segmentation"><a href="#论文阅读-Efficient-Regional-Memory-Network-for-Video-Object-Segmentation" class="headerlink" title="论文阅读-Efficient Regional Memory Network for Video Object Segmentation"></a>论文阅读-Efficient Regional Memory Network for Video Object Segmentation</h1><p>代码地址:<a href="https://github.com/hzxie/RMNet">https://github.com/hzxie/RMNet</a></p><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>最近,几个Space-Time Memory based networks表明,来自过去帧的对象线索(例如视频帧以及分割的对象掩码)对于分割当前帧中的对象很有用。然而,这些方法通过当前帧和过去帧之间的全局到全局匹配来利用内存中的信息,这导致与相似对象的不匹配和高计算复杂度。为了解决这些问题,我们为半监督 VOS 提出了一种新颖的local-to-local匹配解决方案,即区域记忆网络 (RMNet)。在 RMNet 中,精确的区域记忆是通过记忆过去帧中目标对象出现的局部区域来构建的。对于当前查询帧,根据前一帧估计的optical flow跟踪和预测查询区域。所提出的local-to-local匹配有效地缓解了内存和查询帧中相似对象的歧义,这使得信息可以有效地从区域内存传递到查询区域。实验结果表明,所提出的 RMNet 在 DAVIS 和 YouTube-VOS 数据集上优于最先进的方法。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Existing-Problem"><a href="#Existing-Problem" class="headerlink" title="Existing Problem"></a>Existing Problem</h3><p>these methods memorize and match features in the regions without target objects, which lead to mismatching to similar objects and high computational complexity</p><p>mismatching的分类:</p><ul><li>The target object in the current frame matches to the wrong object in the past frame</li><li>The target object in the past frame matches to the wrong object in the current frame</li></ul><p>The situation is shown below:</p><img src="https://s1.ax1x.com/2022/09/22/xFkhef.png" alt="1" style="zoom:67%;" /><h3 id="Solution"><a href="#Solution" class="headerlink" title="Solution"></a>Solution</h3><p>We present the Regional Memory Network (RMNet) for semi-supervised VOS</p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><ul><li>We propose Regional Memory Network (RMNet) for semi-supervised VOS, which memorizes and tracks the regions containing target objects.</li><li>We present Regional Memory Reader that performs local-to-local matching between object regions in the past and current frames, which reduces the computational complexity.</li><li>Experimental results on the DAVIS and YouTube-VOS datasets indicate that the proposed RMNet outperforms the state-of-the-art methods with much faster running speed.</li></ul><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>(1)Propagation-based Methods.</p><p>(2)Matching-based Methods.</p><h2 id="Regional-Memory-Network"><a href="#Regional-Memory-Network" class="headerlink" title="Regional Memory Network"></a>Regional Memory Network</h2><h3 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h3><img src="https://s1.ax1x.com/2022/09/22/xFAEm6.png" alt="network" style="zoom:67%;" /><h3 id="Regional-Feature-Embedding"><a href="#Regional-Feature-Embedding" class="headerlink" title="Regional Feature Embedding"></a>Regional Feature Embedding</h3><h4 id="Regional-Memory-Embedding"><a href="#Regional-Memory-Embedding" class="headerlink" title="Regional Memory Embedding"></a>Regional Memory <strong>Embedding</strong></h4><p><strong>Aim</strong>:To solve the issue that the features outside the regions where the target objects appear may lead to the mismatching to the similar objects in the query frame</p><p><strong>Mask to Regional Attention Map</strong></p><p>get the regional attention map:</p><img src="https://s1.ax1x.com/2022/09/22/xFk6Wd.png" alt="2" style="zoom:67%;" /><img src="https://s1.ax1x.com/2022/09/22/xFk2QI.png" alt="3" style="zoom:67%;" /><p>说明:Mi :the object mask,whose shape is H×W;<strong>(xmin, ymin) and (xmax, ymax)</strong> are the top-left and bottom-right coordinates of the bounding box for the target object</p><p><strong>Regional Memory Key/Value</strong></p><p>the key k^j^ <del>M</del> and value v^j^ <del>M</del> is obtained by the dot product of A^j^ <del>M</del> and the global memory embedding from the memory encoder.</p><p>说明:A^j^ <del>M</del> :the regional attention map of j-th object in the memory frames</p><h4 id="Regional-Query-Embedding"><a href="#Regional-Query-Embedding" class="headerlink" title="Regional Query Embedding"></a>Regional Query Embedding</h4><p><strong>Aim</strong>:alleviates the mismatching to the similar objects in the query frame.</p><p><strong>Object Mask Tracking</strong> </p><p>作用:obtain the possible regions of target objects in the current frame</p><p>实现:we warp the mask M^j^ <del>t−1</del> of the previous frame with the optical flow Ft estimated by the proposed <strong>TinyFlowNet</strong>.</p><p>输出:a rough mask <strong>ˆM^j^ <del>t</del></strong></p><p><strong>Mask to Regional Attention Map</strong></p><p>作用:计算the regional attention map A^j^ <del>Q</del> .计算方法和Regional Memory Embedding的一致,但做了一些更改:</p><p>A^j^ <del>Q</del> = 1 if the number of pixels is lower than a threshold η</p><p><strong>Regional Query Key/Value</strong></p><p>the key k^j^ <del>Q</del> and value v^j^ <del>Q</del> is obtained by the dot product of <strong>A^j^ <del>Q</del></strong> and the global memory embedding from the query encoder.</p><h3 id="Regional-Memory-Reader"><a href="#Regional-Memory-Reader" class="headerlink" title="Regional Memory Reader"></a>Regional Memory Reader</h3><p>compute affinity:</p><img src="https://s1.ax1x.com/2022/09/22/xFkyJH.png" alt="4" style="zoom:67%;" /><p>说明:p = [pt, px, py] and q = [qx, qy],which are the grid cell locations in k^j^ <del>M</del> and k^j^ <del>Q</del></p><p>retrieves the corresponding value from the memory:</p><img src="https://s1.ax1x.com/2022/09/22/xFksFe.png" alt="5" style="zoom:67%;" /><p>get the output of the space-time memory reader at position q:</p><img src="https://s1.ax1x.com/2022/09/22/xFkgSA.png" alt="6" style="zoom:67%;" /><p><strong>R^j^ <del>M</del> and R^j^ <del>Q</del></strong> :the feature matching regions of the j-th object in the memory and query frames</p><img src="https://s1.ax1x.com/2022/09/22/xFkRyt.png" alt="7" style="zoom:67%;" /><p>for below situation,the similarity between p and q is computed as:</p><img src="https://s1.ax1x.com/2022/09/22/xFkWOP.png" alt="8" style="zoom:67%;" /><h3 id="Network-Architecture"><a href="#Network-Architecture" class="headerlink" title="Network Architecture"></a>Network Architecture</h3><h4 id="TinyFlowNet"><a href="#TinyFlowNet" class="headerlink" title="TinyFlowNet"></a>TinyFlowNet</h4><p>the input images are downsampled by 2 before fed into TinyFlowNet.</p><h4 id="Encoder"><a href="#Encoder" class="headerlink" title="Encoder"></a>Encoder</h4><p>Both the memory and query encoders use ResNet50 as the backbone network</p><h4 id="Decoder"><a href="#Decoder" class="headerlink" title="Decoder"></a>Decoder</h4><p>a residual block and two stacks of refinement modules</p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><p>DAVIS 2016 validation set</p><img src="https://s1.ax1x.com/2022/09/22/xFkuMq.png" alt="t1" style="zoom:67%;" /><p>DAVIS 2017 validation set</p><img src="https://s1.ax1x.com/2022/09/22/xFkMLV.png" alt="t2" style="zoom:67%;" /><p>DAVIS 2017 test-dev set</p><img src="https://s1.ax1x.com/2022/09/22/xFkKs0.png" alt="t3" style="zoom:67%;" /><p>YouTube-VOS validation set (2018 version)</p><img src="https://s1.ax1x.com/2022/09/22/xFkmzn.png" alt="t4" style="zoom:67%;" /><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>在本文中,我们提出了用于半监督 VOS 的区域记忆网络 (RMNet)。与基于 STM 的方法相比,RMNet 对包含目标对象的区域进行记忆和跟踪,有效缓解了相似对象的模糊性,同时也降低了特征匹配的计算复杂度。在 DAVIS 和 YouTube-VOS 上的实验结果表明,所提出的方法以更快的运行速度优于最先进的方法。</p>]]></content>
<summary type="html"><h1 id="论文阅读-Efficient-Regional-Memory-Network-for-Video-Object-Segmentation"><a href="#论文阅读-Efficient-Regional-Memory-Network-for-Video-Obj</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2021" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2021/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="VOS" scheme="https://lzl2040.github.io/tags/VOS/"/>
</entry>
<entry>
<title>论文阅读-PANet:Few-Shot Image Semantic Segmentation with Prototype Alignment</title>
<link href="https://lzl2040.github.io/2022/09/20/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-PANet-Few-Shot-Image-Semantic-Segmentation-with-Prototype-Alignment/"/>
<id>https://lzl2040.github.io/2022/09/20/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-PANet-Few-Shot-Image-Semantic-Segmentation-with-Prototype-Alignment/</id>
<published>2022-09-20T04:30:32.000Z</published>
<updated>2022-09-21T08:42:50.878Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-PANet-Few-Shot-Image-Semantic-Segmentation-with-Prototype-Alignment"><a href="#论文阅读-PANet-Few-Shot-Image-Semantic-Segmentation-with-Prototype-Alignment" class="headerlink" title="论文阅读-PANet: Few-Shot Image Semantic Segmentation with Prototype Alignment"></a>论文阅读-PANet: Few-Shot Image Semantic Segmentation with Prototype Alignment</h1><p>代码地址:<a href="https://github.com/kaixin96/PANet">https://github.com/kaixin96/PANet</a></p><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>尽管deep CNNs 在图像语义分割方面取得了巨大进步,但它们通常需要大量密集注释的图像进行训练,并且难以推广到看不见的对象类别。因此,已经开发了few-shot分割来学习仅从几个带注释的示例中执行分割。在本文中,我们从<strong>度量学习的角度</strong>解决了具有挑战性的小样本分割问题,并提出了 PANet,这是一种新的<strong>prototype alignment network</strong>,可以更好地利用支持集的信息。我们的 PANet 从<strong>embedding space</strong>内的一些支持图像中学习特定类别的原型表示,然后通过将每个像素与学习的原型匹配来对查询图像执行分割。通过非参数度量学习,PANet 提供了高质量的原型,这些原型代表了每个语义类,同时区分了不同的类。此外,PANet 在支持和查询之间引入了原型对齐正则化。有了这个,PANet 充分利用了来自支持集的知识,并在few-shot分割上提供了更好的泛化。值得注意的是,我们的模型在 PASCAL-5i 上的 1-shot 和 5-shot 设置的 mIoU 得分分别为 48.1% 和 55.7%,比最先进的方法高出 1.8% 和 8.6%。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Exsiting-Problems"><a href="#Exsiting-Problems" class="headerlink" title="Exsiting Problems"></a>Exsiting Problems</h3><p>(1)Existing few-shot segmentation methods do not <strong>differentiate the knowledge extraction and segmentation process</strong></p><p>(2)They use the annotations of the support set only for masking</p><h3 id="Our-Solution"><a href="#Our-Solution" class="headerlink" title="Our Solution"></a>Our Solution</h3><p>We develop a Prototype Alignment Network (PANet) to tackle few-shot segmentation.</p><p>The overview of our model is shown below:</p><img src="https://s1.ax1x.com/2022/09/20/xPTHL6.png" alt="overview1" style="zoom:67%;" /><h3 id="Advantages"><a href="#Advantages" class="headerlink" title="Advantages"></a>Advantages</h3><p>(1)it introduces no extra learnable parameters and thus is less prone to over-fitting</p><p>(2)the prototype embedding and prediction are performed on the computed feature maps and therefore segmentation requires no extra passes through the network</p><p>(3)the computation cost for inference does not increase.</p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><p>(1)We propose a simple yet effective PANet for few-shot segmentation. The model exploits metric learning over prototypes</p><p>(2)We propose a novel prototype alignment regularization to fully exploit the support knowledge to improve the few-shot learning.</p><p>(3)Our model can be directly applied to learning from a few examples with weak annotations</p><p>(4)Our PANet achieves mIoU of 48.1% and 55.7% on PASCAL-5i for 1-shot and 5-shot settings, outperforming state-of-the-arts by a margin up to 8.6 %.</p><h2 id="Realted-Work"><a href="#Realted-Work" class="headerlink" title="Realted Work"></a>Realted Work</h2><h3 id="Semantic-segmentation"><a href="#Semantic-segmentation" class="headerlink" title="Semantic segmentation"></a>Semantic segmentation</h3><p>**Fully Convolutional Network (FCN):**Fully convolutional networks for semantic segmentation.</p><p>**Dilated convolutions:**(1)Multi-scale context aggregation by dilated convolutions.(2)Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs</p><h3 id="Few-shot-learning"><a href="#Few-shot-learning" class="headerlink" title="Few-shot learning"></a>Few-shot learning</h3><p><strong>metric learning</strong>:(1)Matching networks for one shot learning.(2)Prototypical networks for few-shot learning</p><p><strong>learning the optimization process</strong>:(1)Optimization as a model for few-shot learning.(2)Modelagnostic meta-learning for fast adaptation of deep networks.</p><p><strong>applying graph-based methods</strong>:(1)Few-shot learning with graph neural networks.(2)Learning to propagate labels: Transductive propagation network for few-shot learning.</p><h3 id="Few-shot-segmentation"><a href="#Few-shot-segmentation" class="headerlink" title="Few-shot segmentation"></a>Few-shot segmentation</h3><h2 id="Method"><a href="#Method" class="headerlink" title="Method"></a>Method</h2><h3 id="Method-overview"><a href="#Method-overview" class="headerlink" title="Method overview"></a>Method overview</h3><img src="https://s1.ax1x.com/2022/09/20/xPT7sx.png" alt="overview2" style="zoom:67%;" /><p>说明:feature extractor:VGG-16,which keeps the first 5 convolutional blocks.The stride of <strong>maxpool4 layer</strong> is set to 1.The convolutions in <strong>conv5 block</strong> are replaced by dilated convolutions with dilation set to 2.</p><h3 id="Prototype-learning"><a href="#Prototype-learning" class="headerlink" title="Prototype learning"></a>Prototype learning</h3><p><strong>准备知识:</strong></p><p>(1)early fusion:masks the support images before feeding them into the feature extractor</p><p>(2)late fusion:masks over the feature maps to produce foreground/background features separately</p><p>本篇文章使用(2),因为它保持共享特征提取器的输入一致性。</p><p><strong>相关计算:</strong></p><p>(1)The prototype of class c is computed via masked average pooling:</p><img src="https://s1.ax1x.com/2022/09/20/xPTRdU.png" alt="f1" style="zoom:67%;" /><p>说明:<strong>F<del>c,k</del></strong> :the feature map output by the network for <strong>the image I<del>c,k</del></strong>;</p><p>c indexes the class and k = 1, . . . , K indexes the support image;</p><p><strong>(x, y)</strong> indexes the spatial locations;</p><p><strong>1(·)</strong> is an indicator function, outputting value 1 if the argument is true or 0 otherwise</p><p>(2)compute the prototype of background</p><img src="https://s1.ax1x.com/2022/09/20/xPThi4.png" alt="f2" style="zoom:67%;" /><h3 id="Non-parametric-metric-learning"><a href="#Non-parametric-metric-learning" class="headerlink" title="Non-parametric metric learning"></a>Non-parametric metric learning</h3><p>(1)for each p<del>j</del> ∈ P,calculate a probability map ̃Mq</p><img src="https://s1.ax1x.com/2022/09/20/xPTWoF.png" alt="f3" style="zoom:67%;" /><p>说明:**d:**distance function.we use cosine distance(Multiply the cosine distance by a factor α)</p><p>P = {p<del>c</del>|c ∈ C<del>i</del>}∪{p<del>bg</del>}</p><p>**Fq:**the query feature map</p><p>(2)get the predicted segmentation mask:</p><img src="https://s1.ax1x.com/2022/09/20/xPT4JJ.png" alt="f4" style="zoom:67%;" /><p>(3)calculate the segmentation loss using the probability map:</p><img src="https://s1.ax1x.com/2022/09/20/xPTIzR.png" alt="f5" style="zoom:67%;" /><h3 id="Prototype-alignment-regularization-PAR"><a href="#Prototype-alignment-regularization-PAR" class="headerlink" title="Prototype alignment regularization (PAR)"></a>Prototype alignment regularization (PAR)</h3><p>(1)perform masked average pooling accordingly on the query features and get another set of prototypes</p><p>(2)use the nonparametric method to predict the segmentation masks for <strong>the support images</strong></p><p>the segmentation probability of the support image I<del>c,k</del>:</p><img src="https://s1.ax1x.com/2022/09/20/xPT5W9.png" alt="f6" style="zoom:67%;" /><p>(3)calculate a loss L<del>PAR</del> by comparing the ground truth annotations with the predictions</p><img src="https://s1.ax1x.com/2022/09/20/xPTTQ1.png" alt="f7" style="zoom:67%;" /><p>(4)the total loss</p><img src="https://s1.ax1x.com/2022/09/20/xP7lwT.png" alt="f8" style="zoom:67%;" /><p>说明:λ=1</p><h3 id="Generalization-to-weaker-annotations"><a href="#Generalization-to-weaker-annotations" class="headerlink" title="Generalization to weaker annotations"></a>Generalization to weaker annotations</h3><p>(1)it accepts weaker annotations on the support set, such as scribbles and bounding boxes indicating the foreground objects of interest</p><p>(2)our model can quickly adapt to updated annotations with little computation overhead and thus can be applied in interactive segmentation.</p><h2 id="Experiments"><a href="#Experiments" class="headerlink" title="Experiments"></a>Experiments</h2><p>1-way 1-shot and 1-way 5-shot segmentation on PASCAL-5i dataset using mean-IoU metric:</p><img src="https://s1.ax1x.com/2022/09/20/xP78kF.png" alt="t1" style="zoom:67%;" /><p>1-way 1-shot and 1-way 5-shot segmentation on PASCAL-5i dataset using binary-IoU metric</p><img src="https://s1.ax1x.com/2022/09/20/xP71TU.png" alt="t2" style="zoom:67%;" /><p>2-way 1-shot and 2-way 5-shot segmentation on PASCAL-5i dataset:</p><img src="https://s1.ax1x.com/2022/09/20/xP7QmV.png" alt="t3" style="zoom:67%;" /><p>1-way 1-shot and 1-way 5-shot segmentation on MS COCO dataset:</p><img src="https://s1.ax1x.com/2022/09/20/xP7KO0.png" alt="t4" style="zoom:67%;" /><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>我们提出了一种新颖的 PANet,用于基于度量学习的小样本分割。PANet 能够从支持集中提取稳健的原型,并使用非参数距离计算进行分割。通过提出的 PAR,我们的模型可以进一步利用支持信息来辅助训练。在没有任何解码器结构或后处理步骤的情况下,我们的 PANet 大大优于以前的工作。</p>]]></content>
<summary type="html">a new prototype alignment network</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="ICCV" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/ICCV/"/>
<category term="2019" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/ICCV/2019/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="FSS" scheme="https://lzl2040.github.io/tags/FSS/"/>
</entry>
<entry>
<title>论文阅读-Modular Interactive Video Object Segmentation:Interaction-to-Mask,Propagation and Difference-Aware Fusion</title>
<link href="https://lzl2040.github.io/2022/09/18/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Modular-Interactive-Video-Object-Segmentation-Interaction-to-Mask-Propagation-and-Difference-Aware-Fusion/"/>
<id>https://lzl2040.github.io/2022/09/18/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Modular-Interactive-Video-Object-Segmentation-Interaction-to-Mask-Propagation-and-Difference-Aware-Fusion/</id>
<published>2022-09-18T15:40:49.000Z</published>
<updated>2022-09-21T08:43:03.856Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Modular-Interactive-Video-Object-Segmentation-Interaction-to-Mask-Propagation-and-Difference-Aware-Fusion"><a href="#论文阅读-Modular-Interactive-Video-Object-Segmentation-Interaction-to-Mask-Propagation-and-Difference-Aware-Fusion" class="headerlink" title="论文阅读-Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion"></a>论文阅读-Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion</h1><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>我们提出了模块化交互式 VOS (MiVOS) 框架,该框架将interaction-to-mask和mask propagation解耦,从而实现更高的通用性和更好的性能。单独训练的交互模块将用户交互转换为对象掩码,然后由我们的传播模块在读取space-time memory时使用新的 top-k 过滤策略进行时间传播。为了有效地考虑用户的意图,提出了一种新颖的difference-aware module来学习如何在每次交互之前和之后正确融合掩码,这些掩码通过使用space-time memory与目标帧对齐。我们在 DAVIS 上使用不同形式的用户交互(例如,涂鸦、点击)对我们的方法进行了定性和定量评估,以表明我们的方法优于当前最先进的算法,同时需要更少的帧交互,在泛化方面具有额外优势 针对不同类型的用户交互。我们贡献了一个具有 480 万帧像素精确分割的大规模合成 VOS 数据集,以配合我们的源代码,以促进未来的研究。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="interactive-VOS-iVOS"><a href="#interactive-VOS-iVOS" class="headerlink" title="interactive VOS(iVOS)"></a>interactive VOS(iVOS)</h3><p><strong>特点:</strong> interactive VOS方法将用户交互(例如,涂鸦或点击)作为输入,用户可以在其中迭代地细化结果直到满意。</p><p><strong>包含的两个任务:</strong></p><ul><li>interaction understanding</li><li>temporal propagation</li></ul><h3 id="Existing-Problem"><a href="#Existing-Problem" class="headerlink" title="Existing Problem"></a>Existing Problem</h3><p>(1)The <strong>strong coupling</strong> limits the form of user interaction (e.g., scribbles only) and makes training difficult.Attempts to decouple the two tasks fail to reach state-of-the-art accuracy as user’s intent cannot be adequately taken into account in the propagation process.</p><p>强耦合限制了用户交互的形式(例如,仅涂鸦)并使训练变得困难。由于在传播过程中无法充分考虑用户的意图,尝试将这两个任务解耦未能达到最先进的准确性 .</p><p>(2)naive decoupling may lead to loss of user’s intent as the original interaction is no longer available in the propagation stage.</p><p>naive解耦可能会导致失去用户的意图,因为原始交互在传播阶段不再可用。</p><h3 id="Solution"><a href="#Solution" class="headerlink" title="Solution"></a>Solution</h3><p>We present a decoupled modular framework to address the iVOS problem.</p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><ul><li>We innovate on the decoupled interaction-propagation framework and show that this approach is simple, effective, and generalizable.我们对解耦的交互传播框架进行了创新,并表明这种方法简单、有效且可推广。</li><li>We propose a novel lightweight top-k filtering scheme for the attention-based memory read operation in mask generation during propagation.我们提出了一种新颖的轻量级 top-k 过滤方案,用于在传播过程中的掩码生成中基于注意力的内存读取操作。</li><li>We propose a novel difference-aware fusion module to faithfully capture the user’s intent which improves iVOS accuracy and reduces the amount of user interaction.我们提出了一种新颖的差异感知融合模块来忠实地捕捉用户的意图,从而提高 iVOS 的准确性并减少用户交互量。</li><li>We contribute a large-scale synthetic VOS dataset with 4.8M frames to accompany our source codes to facilitate future research.我们提供了一个具有 480 万帧的大规模合成 VOS 数据集,以配合我们的源代码,以促进未来的研究。</li></ul><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>Progress in iVOS is shown below:</p><img src="https://s1.ax1x.com/2022/09/20/xCLWfe.png" alt="progress" style="zoom:67%;" /><h3 id="Semi-Supervised-Video-Object-Segmentation"><a href="#Semi-Supervised-Video-Object-Segmentation" class="headerlink" title="Semi-Supervised Video Object Segmentation"></a>Semi-Supervised Video Object Segmentation</h3><p><strong>defination:</strong> segment a specific object throughout a video given only a fully-annotated mask in the first frame.</p><h3 id="Interactive-Video-Object-Segmentation-iVOS"><a href="#Interactive-Video-Object-Segmentation-iVOS" class="headerlink" title="Interactive Video Object Segmentation (iVOS)"></a>Interactive Video Object Segmentation (iVOS)</h3><p><strong>focus:</strong></p><p>(1)scribble interaction</p><p>(2)click interaction</p><h3 id="Interactive-Image-Segmentation"><a href="#Interactive-Image-Segmentation" class="headerlink" title="Interactive Image Segmentation"></a>Interactive Image Segmentation</h3><h2 id="Method"><a href="#Method" class="headerlink" title="Method"></a>Method</h2><h3 id="Initial-Work"><a href="#Initial-Work" class="headerlink" title="Initial Work"></a>Initial Work</h3><p>Initially, the user selects and interactively annotates one frame (e.g., using scribbles or clicks) to produce a mask.</p><p>最初,用户选择并交互式地注释一帧(例如,使用涂鸦或点击)以生成蒙版。</p><h3 id="MiNet-Overview"><a href="#MiNet-Overview" class="headerlink" title="MiNet Overview"></a>MiNet Overview</h3><h4 id="Character-Denfination"><a href="#Character-Denfination" class="headerlink" title="Character Denfination"></a>Character Denfination</h4><p>(1)We denote <strong>r</strong> as the current interaction round</p><p>(2)the user-interacted frame index in the r-th round is <strong>tr</strong></p><p>(3)the mask results of the r-th round is <strong>Mr</strong></p><p>(4)the mask of individual j-th frame is denoted as <strong>M rj</strong></p><h4 id="Core-Component"><a href="#Core-Component" class="headerlink" title="Core Component"></a>Core Component</h4><p><strong>interaction-to-mask</strong> :allowing the user to obtain real-time feedback and achieve a satisfactory result on a single frame</p><p><strong>mask propagation:</strong> the corrected mask is bidirectionally propagated</p><p><strong>difference-aware fusion:</strong> use the two sequences while avoiding possible decay or loss of user’s intent.</p><p><strong>how to capture the user’s intent</strong>:use the difference in the selected mask before and after user interaction</p><h4 id="Figure"><a href="#Figure" class="headerlink" title="Figure"></a>Figure</h4><img src="https://s1.ax1x.com/2022/09/20/xCL4ld.png" alt="overview" style="zoom:80%;" /><h3 id="Interaction-to-Mask"><a href="#Interaction-to-Mask" class="headerlink" title="Interaction-to-Mask"></a>Interaction-to-Mask</h3><h4 id="Scribble-to-Mask-S2M"><a href="#Scribble-to-Mask-S2M" class="headerlink" title="Scribble-to-Mask(S2M)"></a>Scribble-to-Mask(S2M)</h4><p><strong>Goal:</strong> produce a single-image segmentation in real time given input scribbles</p><p><strong>backbone:</strong> DeepLabV3+ semantic segmentation network</p><h4 id="Local-Control"><a href="#Local-Control" class="headerlink" title="Local Control"></a>Local Control</h4><p><strong>previous state-of-the-art approach</strong> :it may harm the global result when only local fine adjustment is needed toward the end of the segmentation process.</p><p>the source of previous state-of-the-art approach:</p><p>Konstantin Sofiiuk, Ilia Petrov, Olga Barinova, and Anton Konushin. f-brs: Rethinking backpropagating refinement for interactive segmentation. In CVPR, 2020. 1, 2, 3, 4, 7, 8</p><p><strong>our approach</strong> :it is straightforward to assert local control by <strong>limiting the interactive algorithm to apply in a user-specified region</strong></p><p><strong>the comparison of above two approaches:</strong></p><img src="https://s1.ax1x.com/2022/09/20/xCL56A.png" alt="comparison1" style="zoom:67%;" /><h3 id="Temporal-Propagation"><a href="#Temporal-Propagation" class="headerlink" title="Temporal Propagation"></a>Temporal Propagation</h3><p>**Goal:**tracks the object and produces corresponding masks in subsequent frames.</p><h4 id="Memory-Read-with-Top-k-Filtering"><a href="#Memory-Read-with-Top-k-Filtering" class="headerlink" title="Memory Read with Top-k Filtering"></a>Memory Read with Top-k Filtering</h4><p>(1)计算affinity</p><img src="https://s1.ax1x.com/2022/09/20/xCOK76.png" alt="f1" style="zoom:67%;" /><p>F ∈ <strong>R THW ×HW</strong> represents the affinity between a query position and a memory position</p><p>(2)filter the affinities such that only the top-k entries are kept</p><img src="https://s1.ax1x.com/2022/09/20/xCOu0x.png" alt="f2" style="zoom:67%;" /><p>作用:effectively removes noises regardless of the sequence length</p><p>优点:increase robustness and overcome the overhead of top-k</p><p>(3)For query position j, <strong>the feature mj</strong> is read from memory by:</p><img src="https://s1.ax1x.com/2022/09/20/xCO1hD.png" alt="f3" style="zoom:67%;" /><p>(4)concatenate the read features with <strong>vQ</strong></p><p>the process is shown below:</p><img src="https://s1.ax1x.com/2022/09/20/xCLhSH.png" alt="process" style="zoom:67%;" /><h4 id="Propagation-strategy"><a href="#Propagation-strategy" class="headerlink" title="Propagation strategy"></a>Propagation strategy</h4><p>our propagation scheme:</p><img src="https://s1.ax1x.com/2022/09/20/xCOltO.png" style="zoom:67%;" /><h3 id="Difference-Aware-Fusion"><a href="#Difference-Aware-Fusion" class="headerlink" title="Difference-Aware Fusion"></a>Difference-Aware Fusion</h3><p>(1)compute the positive and negative changes separately as two masks D+ and D−</p><img src="https://s1.ax1x.com/2022/09/20/xCO89e.png" alt="f4" style="zoom:67%;" /><p>说明:(·)+ is the max(·, 0)</p><p>(2)compute the aligned masks</p><img src="https://s1.ax1x.com/2022/09/20/xCOQAK.png" alt="f5" style="zoom:67%;" /><p>说明:W来自Memory Read with Top-k Filtering中的第二步</p><p>(3)feed these features into a simple five-layer residual network which is terminated by a sigmoid to output a final fused mask</p><p>Mechanism of the difference-aware fusion module:</p><img src="https://s1.ax1x.com/2022/09/20/xCOG1H.png" alt="process2" style="zoom:67%;" /><p>说明:</p><p><img src="https://s1.ax1x.com/2022/09/20/xCXm8g.png" alt="introducion"></p><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><p>Performance on the DAVIS interactive validation set:</p><img src="https://s1.ax1x.com/2022/09/20/xCXePS.png" alt="table" style="zoom:67%;" /><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>我们提出 MiVOS,一种由三个模块组成的新型解耦方法:Interaction-to-Mask, Propagation and Difference-Aware Fusion.通过将交互与传播解耦,MiVOS 是通用的,并且不受交互类型的限制。另一方面,所提出的fusion module通过忠实地捕捉用户的意图来协调交互和传播,并减少在解耦过程中丢失的信息,从而使 MiVOS 既准确又高效。我们希望我们的 MiVOS 能够激发和激发 iVOS 的未来研究</p>]]></content>
<summary type="html"><h1 id="论文阅读-Modular-Interactive-Video-Object-Segmentation-Interaction-to-Mask-Propagation-and-Difference-Aware-Fusion"><a href="#论文阅读-Modul</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2021" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2021/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="VOS" scheme="https://lzl2040.github.io/tags/VOS/"/>
</entry>
<entry>
<title>论文笔记-论文常用高级词汇/句式</title>
<link href="https://lzl2040.github.io/2022/09/18/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0-%E8%AE%BA%E6%96%87%E5%B8%B8%E7%94%A8%E9%AB%98%E7%BA%A7%E8%AF%8D%E6%B1%87-%E5%8F%A5%E5%BC%8F/"/>
<id>https://lzl2040.github.io/2022/09/18/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0-%E8%AE%BA%E6%96%87%E5%B8%B8%E7%94%A8%E9%AB%98%E7%BA%A7%E8%AF%8D%E6%B1%87-%E5%8F%A5%E5%BC%8F/</id>
<published>2022-09-18T14:08:05.000Z</published>
<updated>2022-09-28T08:56:20.732Z</updated>
<content type="html"><![CDATA[<h1 id="论文笔记-论文常用高级词汇-句式"><a href="#论文笔记-论文常用高级词汇-句式" class="headerlink" title="论文笔记-论文常用高级词汇/句式"></a>论文笔记-论文常用高级词汇/句式</h1><h2 id="leverage-提高-利用"><a href="#leverage-提高-利用" class="headerlink" title="leverage.提高,利用"></a>leverage.提高,利用</h2><p>示例:we propose to <strong>leverage</strong> them also for supervising the few-shot learning process</p><h2 id="novel-新颖的"><a href="#novel-新颖的" class="headerlink" title="novel.新颖的"></a>novel.新颖的</h2><p>示例:a novel module</p><h2 id="propose-提出"><a href="#propose-提出" class="headerlink" title="propose.提出"></a>propose.提出</h2><p>示例:a new method is proposed</p><h2 id="tailor-量身定制"><a href="#tailor-量身定制" class="headerlink" title="tailor.量身定制"></a>tailor.量身定制</h2><p>示例:tailored pipeline</p><h2 id="alleviate-减轻-缓和"><a href="#alleviate-减轻-缓和" class="headerlink" title="alleviate.减轻,缓和"></a>alleviate.减轻,缓和</h2><p>示例:alleviate requirements/problems</p><h2 id="aforementioned-上述的"><a href="#aforementioned-上述的" class="headerlink" title="aforementioned.上述的"></a>aforementioned.上述的</h2><p>示例:to deal with the aforementioned challenges</p><h2 id="tackle-解决"><a href="#tackle-解决" class="headerlink" title="tackle.解决"></a>tackle.解决</h2><p>示例:we develop a network to <strong>tackle</strong> few-shot segmentation</p><h2 id="integrate-整合-集成"><a href="#integrate-整合-集成" class="headerlink" title="integrate.整合,集成"></a>integrate.整合,集成</h2>]]></content>
<summary type="html"><h1 id="论文笔记-论文常用高级词汇-句式"><a href="#论文笔记-论文常用高级词汇-句式" class="headerlink" title="论文笔记-论文常用高级词汇/句式"></a>论文笔记-论文常用高级词汇/句式</h1><h2 id="leverage-</summary>
<category term="论文笔记" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
</entry>
<entry>
<title>论文阅读-Delving Deep into Many-to-many Attention for Few-shot Video Object Segmentation Segmentation</title>
<link href="https://lzl2040.github.io/2022/09/16/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Delving-Deep-into-Many-to-many-Attention-for-Few-shot-Video-Object-Segmentation/"/>
<id>https://lzl2040.github.io/2022/09/16/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Delving-Deep-into-Many-to-many-Attention-for-Few-shot-Video-Object-Segmentation/</id>
<published>2022-09-16T13:05:14.000Z</published>
<updated>2022-09-21T08:42:57.807Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Delving-Deep-into-Many-to-many-Attention-for-Few-shot-Video-Object-Segmentation"><a href="#论文阅读-Delving-Deep-into-Many-to-many-Attention-for-Few-shot-Video-Object-Segmentation" class="headerlink" title="论文阅读-Delving Deep into Many-to-many Attention for Few-shot Video Object Segmentation"></a>论文阅读-Delving Deep into Many-to-many Attention for Few-shot Video Object Segmentation</h1><p>代码:<a href="https://github.com/scutpaul/DANet">https://github.com/scutpaul/DANet</a></p><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>本文解决了 Few-Shot Video Object Segmentation (FSVOS) 的任务,即将查询视频中的对象分割为在几个标记的支持图像中指定的特定类别。关键是对查询视频和支持图像之间的关系进行建模,以传播对象信息。这是一个多对多的问题,通常依赖于计算密集型的full-rank注意力。在本文中,我们提出了一种新颖的Domain Agent Network (DAN),将full-rank注意力分解为两个较小的注意力。我们将查询视频的单帧视为域代理,在支持图像和查询视频之间架起桥梁。我们的 DAN 允许线性空间和时间复杂度,而不是原始的二次形式,而不会损失性能。此外,我们引入了一种将元学习与在线学习相结合的学习策略,以进一步提高分割精度。我们在 Youtube-VIS 数据集上构建 FSVOS 基准并进行实验,以证明我们的方法在计算成本和准确性方面都优于baseline,实现了最先进的性能。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="VOS分类"><a href="#VOS分类" class="headerlink" title="VOS分类"></a>VOS分类</h3><p>(1)unsupervised VOS:segments primary objects in the videos without any human intervention</p><p>(2)semi-supervised VOS:gives the ground truth segmentation of the first frame and propagates the labeled object information into subsequent frames.</p><p>本文与上面两种的对比:</p><img src="https://s1.ax1x.com/2022/09/16/xSYiRO.png" alt="comparison2" style="zoom:67%;" /><h3 id="FSVOS定义"><a href="#FSVOS定义" class="headerlink" title="FSVOS定义"></a>FSVOS定义</h3><p>FSVOS aims to segment new object classes across query videos with only a few annotated support images</p><p>FSVOS 旨在仅使用少量带注释的支持图像在查询视频中分割新的对象类</p><h3 id="存在的问题"><a href="#存在的问题" class="headerlink" title="存在的问题"></a>存在的问题</h3><p>Constructing correlation among support images and query videos is a many-to-many problem and directly using these full-rank attentions in FSVOS suffers from expensive computational cost</p><h3 id="过去的解决办法"><a href="#过去的解决办法" class="headerlink" title="过去的解决办法"></a>过去的解决办法</h3><ul><li>The prototypebased methods,缺点:loses structural information of the support images.</li><li>The attentionbased methods,缺点:the computational complexity grows exponentially as the number of input images grows.</li></ul><p>它们与本文的方法对比:</p><img src="https://s1.ax1x.com/2022/09/16/xSYCi6.png" alt="comparison1" style="zoom:67%;" /><h3 id="推断"><a href="#推断" class="headerlink" title="推断"></a>推断</h3><p>We hypothesize that the original attention matrix can be replaced with a product of two smaller attention matrices through an agent t.</p><h3 id="论文的解决办法"><a href="#论文的解决办法" class="headerlink" title="论文的解决办法"></a>论文的解决办法</h3><ul><li>we propose a novel Domain Agent Network (DAN),which treats a single frame of the query video as the agent for this video domain.</li><li>we propose a learning strategy for FSVOS by combining meta-learning with online learning</li></ul><h3 id="贡献"><a href="#贡献" class="headerlink" title="贡献"></a>贡献</h3><ul><li>We delve into the conventional many-to-many attention and prove that the original attention matrix can be replaced by the product of two smaller attention matrices bridged by an agent.</li><li>We propose a novel domain agent network based on theoretical support, balancing the accuracy, computational burden, and speed</li><li>We present a learning strategy that combines metalearning and online learning to improve the generalization ability of segmentation and category-specific feature representations.</li></ul><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>(1)Video Object Segmentation</p><p>(2)Few-shot Semantic Segmentation</p><p>(3)Many-to-many Attention</p><p>(4)Online Learning</p><h2 id="Theoretical-Support-for-the-Hypothesis"><a href="#Theoretical-Support-for-the-Hypothesis" class="headerlink" title="Theoretical Support for the Hypothesis"></a>Theoretical Support for the Hypothesis</h2><p><strong>前提知识:</strong></p><p>dot-thenexponentiate function:</p><img src="https://s1.ax1x.com/2022/09/16/xSY8yQ.png" alt="f1" style="zoom: 67%;" /><p>a positive random feature mapping function can be used to approximate the softmax-kernel function without bias:</p><img src="https://s1.ax1x.com/2022/09/16/xSY1SS.png" style="zoom:67%;" /><p>decompose the full-rank attention matrix into the following form:</p><img src="https://s1.ax1x.com/2022/09/16/xSY3Qg.png" alt="f3" style="zoom:67%;" /><p><strong>推导过程:</strong></p><p>approximate the two attention matrices:</p><img src="https://s1.ax1x.com/2022/09/17/xS0T81.png" alt="formula4" style="zoom:67%;" /><p>the Eq:</p><img src="https://s1.ax1x.com/2022/09/17/xS07gx.png" alt="formula9" style="zoom:67%;" /><p>restate the replaced matrix in Eq to the following:</p><img src="https://s1.ax1x.com/2022/09/17/xS0559.png" alt="formula5" style="zoom:67%;" /><p>extract the middle multiplication part:</p><img src="https://s1.ax1x.com/2022/09/17/xS0oCR.png" alt="formula6" style="zoom:67%;" /><p>get the replaced attention matrix as follows:</p><img src="https://s1.ax1x.com/2022/09/17/xS0jVe.png" alt="formula7" style="zoom:67%;" /><img src="https://s1.ax1x.com/2022/09/17/xS0ObD.png" alt="formula8" style="zoom:67%;" /><h2 id="Domain-Agent-Network"><a href="#Domain-Agent-Network" class="headerlink" title="Domain Agent Network"></a>Domain Agent Network</h2><h3 id="Method-Overview"><a href="#Method-Overview" class="headerlink" title="Method Overview"></a>Method Overview</h3><p><strong>overall network:</strong></p><img src="https://s1.ax1x.com/2022/09/16/xSYPJK.png" alt="architecture" style="zoom:80%;" /><p><strong>components</strong>:</p><ul><li>an encoder network</li><li>a domain agent attention module</li><li>a decoder network</li></ul><h3 id="Encoder-and-Decoder"><a href="#Encoder-and-Decoder" class="headerlink" title="Encoder and Decoder"></a>Encoder and Decoder</h3><p><strong>Encoder</strong>:We use a Siamese-architecture for designing encoders that share the same weight.</p><p>encoder backbone:ResNet-50 without the block-4</p><p>output features:we compute features for foreground objects by weighting the support features with the ground truth masks</p><p><strong>Decoder</strong>:based on the upsample operation and the skip-connection</p><p>decoder input:we concatenate the feature values of the query set vQ with the attention features vA,denoted as <strong>f a</strong>.</p><h3 id="Domain-Agent-Attention-Module"><a href="#Domain-Agent-Attention-Module" class="headerlink" title="Domain Agent Attention Module"></a>Domain Agent Attention Module</h3><p><strong>agent选取:</strong>we use the middle frame as the agent for a video to guarantee the learned channel-wise attention is informative</p><p><strong>过程:</strong></p><p>(1)the query features are mapping to queries qQ and key-value pairs kQ - vQ through a single convolutional layer.</p><p>So are the support features.The dimensions are as follows:</p><img src="https://s1.ax1x.com/2022/09/17/xSB92t.png" alt="figure3" style="zoom:67%;" /><p>(2)calculate the attention matrix AQt and AtS</p><img src="https://s1.ax1x.com/2022/09/17/xS0vUH.png" alt="formula8" style="zoom:67%;" /><p>(3)obtain the attention feature vA</p><img src="https://s1.ax1x.com/2022/09/17/xS0LDO.png" alt="formula9" style="zoom:67%;" /><p>comparison between conventional full-rank attention and our domain agent attention:</p><img src="https://s1.ax1x.com/2022/09/17/xSBiKf.png" alt="figure6" style="zoom:67%;" /><h3 id="Learning-Strategy"><a href="#Learning-Strategy" class="headerlink" title="Learning Strategy"></a>Learning Strategy</h3><p>During the training phase, we use meta-learning to learn generic semantics-aware object segmentation.</p><p>During the testing phase,to better adapt features into the domain of the new class, we propose to use the online learning</p><p><strong>comparison:</strong></p><img src="https://s1.ax1x.com/2022/09/17/xSBCxP.png" alt="figure4" style="zoom:67%;" /><h2 id="Experiment"><a href="#Experiment" class="headerlink" title="Experiment"></a>Experiment</h2><p>Comparisons to existing applicable methods:</p><img src="https://s1.ax1x.com/2022/09/17/xSBZ5j.png" alt="table1" style="zoom:67%;" /><h2 id="Conclusion"><a href="#Conclusion" class="headerlink" title="Conclusion"></a>Conclusion</h2><p>In this paper, we propose a novel domain agent network for solving the few-shot video object segmentation task.The key idea is to decompose the typical manyto-many attention matrix into the product of two smaller ones through an agent.</p>]]></content>
<summary type="html"><h1 id="论文阅读-Delving-Deep-into-Many-to-many-Attention-for-Few-shot-Video-Object-Segmentation"><a href="#论文阅读-Delving-Deep-into-Many-to-many-</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="CVPR" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/"/>
<category term="2021" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/CVPR/2021/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="VOS" scheme="https://lzl2040.github.io/tags/VOS/"/>
</entry>
<entry>
<title>论文阅读-Prototype Mixture Models for Few-shot Semantic Segmentation</title>
<link href="https://lzl2040.github.io/2022/09/15/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Prototype-Mixture-Models-for-Few-shot-Semantic-Segmentation/"/>
<id>https://lzl2040.github.io/2022/09/15/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB-Prototype-Mixture-Models-for-Few-shot-Semantic-Segmentation/</id>
<published>2022-09-15T13:14:12.000Z</published>
<updated>2022-09-21T08:42:41.710Z</updated>
<content type="html"><![CDATA[<h1 id="论文阅读-Prototype-Mixture-Models-for-Few-shot-Semantic-Segmentation"><a href="#论文阅读-Prototype-Mixture-Models-for-Few-shot-Semantic-Segmentation" class="headerlink" title="论文阅读-Prototype Mixture Models for Few-shot Semantic Segmentation"></a>论文阅读-Prototype Mixture Models for Few-shot Semantic Segmentation</h1><p>代码:<a href="https://github.com/Yang-Bob/PMMs">https://github.com/Yang-Bob/PMMs</a></p><h2 id="Abstract"><a href="#Abstract" class="headerlink" title="Abstract"></a>Abstract</h2><p>少样本分割具有挑战性,因为支持和查询图像中的对象在外观和姿势上可能存在显着差异。使用直接从支持图像获取的单个原型来分割查询图像会导致语义模糊(semantic ambiguity)。在本文中,我们提出了原型混合模型(PMM),它将不同的图像区域与多个原型相关联,以强制执行基于原型的语义表示。通过Expectation-Maximization algorithm估计,PMM 结合了来自有限支持图像的丰富的通道和空间语义。作为表示和分类器,PMM 充分利用语义来激活查询图像中的对象,同时以<strong>双工方式</strong>(duplex manner)抑制背景区域。</p><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Task-introduction"><a href="#Task-introduction" class="headerlink" title="Task introduction"></a>Task introduction</h3><p>Given a few examples, termed support images, and the related segmentation masks, few-shot segmentation aims to segment the query images based on a feature representation learned on training images</p><p>给定一些示例,称为支持图像和相关的分割掩码,小样本分割旨在基于在训练图像上学习的特征表示来分割查询图像</p><h3 id="The-concept-of-prototype"><a href="#The-concept-of-prototype" class="headerlink" title="The concept of prototype"></a>The concept of prototype</h3><p>refers to a weight vector calculated with global average pooling guided by ground-truth masks embedded in feature maps.</p><p>是指使用嵌入在特征图中的ground-truth mask引导的global average pooling计算的权重向量。</p><h3 id="Exist-Problem"><a href="#Exist-Problem" class="headerlink" title="Exist Problem"></a>Exist Problem</h3><p>the semantic ambiguity problem caused by global average pooling remains unsolved</p><p>global average pooling引起的语义歧义问题仍未解决</p><h3 id="Solution"><a href="#Solution" class="headerlink" title="Solution"></a>Solution</h3><p>we propose prototype mixture models (PMMs) and focus on solving the semantic ambiguity problem in a systematic manner.</p><p>我们提出了原型混合模型(PMM),并专注于以系统的方式解决语义歧义问题。</p><p>the comparison between the single prototype model (upper) based on global average pooling and prototype mixture model is shown below:</p><p><img src="https://s1.ax1x.com/2022/09/16/vzcQcn.png" alt="comparison"></p><h3 id="Contributions"><a href="#Contributions" class="headerlink" title="Contributions"></a>Contributions</h3><p>(1)We propose prototype mixture models (PMMs), with the target to enhance few-shot semantic segmentation by fully leveraging semantics of limited support image(s).</p><p>(2)We propose a duplex strategy, which treats PMMs as both representations and classifiers, to activate spatial and channel-wised semantics for segmentation.</p><p>(3)We assemble PMMs to RPMMs using a residual structure and significantly improve upon the state-of-the-arts</p><h2 id="Related-Work"><a href="#Related-Work" class="headerlink" title="Related Work"></a>Related Work</h2><p>(1)Semantic Segmentation</p><p>(2)Few-shot Learning</p><p>(3)Few-shot Segmentation</p><p>ref paper:</p><ul><li>Shaban, A., Bansal, S., Liu, Z., Essa, I., Boots, B.: One-shot learning for semantic segmentation. In: BMVC. (2017)</li><li>Dong, N., Xing, E.P.: Few-shot semantic segmentation with prototype learning. In: BMVC. (2018) 79</li><li>Zhang, X., Wei, Y., Yang, Y., Huang, T.: Sg-one: Similarity guidance network for one-shot semantic segmentation. CoRR abs/1810.09091 (2018)</li><li>Wang, K., Liew, J., Zou, Y., Zhou, D., Feng, J.: Panet: Few-shot image semantic segmentation with prototype alignment. (2019) 622–631</li><li>Zhang, C., Lin, G., Liu, F., Yao, R., Shen, C.: Canet: Class-agnostic segmentation networks with iterative refinement and attentive few-shot learning. In: IEEE CVPR. (2019) 5217–5226</li><li>Nguyen, K., Todorovic, S.: Feature weighting and boosting for few-shot segmentation. In: IEEE ICCV. (2019) 622–631</li></ul><h2 id="Method"><a href="#Method" class="headerlink" title="Method"></a>Method</h2><h3 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h3><p><img src="https://s1.ax1x.com/2022/09/16/vzcKpj.png" alt="newwork"></p><p>说明:S+ corresponds to feature vectors within the mask of the support image and S− those outside the mask.</p><p>S+ is used to learn foreground PMMs+ corresponding to object parts, and S− to learn background PMMs−</p><h3 id="Prototype-Mixture-Models"><a href="#Prototype-Mixture-Models" class="headerlink" title="Prototype Mixture Models"></a>Prototype Mixture Models</h3><p><strong>Models</strong></p><p>PMMs are defined as a probability mixture model which linearly combine probabilities from base distributions, as:</p><img src="https://s1.ax1x.com/2022/09/16/vzcXgs.png" style="zoom:50%;" /><p>Based on the vector distance, PMMs are defined as:</p><img src="https://s1.ax1x.com/2022/09/16/vzcjvn.png" style="zoom:50%;" /><img src="https://s1.ax1x.com/2022/09/16/vzcLCQ.png" style="zoom:50%;" /><p><strong>Model Learning</strong></p><p>we calculate the expectation of the sample si as</p><img src="https://s1.ax1x.com/2022/09/16/vzcO3j.png" style="zoom:50%;" /><p>the expectation is used to update the mean vectors of PMMs, as</p><img src="https://s1.ax1x.com/2022/09/16/vzcb4g.png" style="zoom:50%;" /><h3 id="Few-shot-Segmentation"><a href="#Few-shot-Segmentation" class="headerlink" title="Few-shot Segmentation"></a>Few-shot Segmentation</h3><p><strong>PMMs as Representation (P-Match)</strong> </p><p>组成:P-Match refers to an activation operation consists of prototype upsampling, feature concatenation, and semantic segmentation using convolution</p><p>公式:</p><img src="https://s1.ax1x.com/2022/09/16/vzc0j1.png" alt="formula1" style="zoom:50%;" /><p>作用:With P-Match, semantic information about the extent of the complete object is incorporated into the query features for semantic segmentation.</p><p><strong>PMMs as Classifiers (P-Conv)</strong></p><p>组成:P-Conv first multiplies each prototype vector with the query feature Q in an <strong>element-wise manner</strong> and then the output is applied Softmax across channels</p><p>公式:</p><img src="https://s1.ax1x.com/2022/09/16/vzcDnx.png" alt="formula2" style="zoom:50%;" /><img src="https://s1.ax1x.com/2022/09/16/vzcwcR.png" alt="formula3" style="zoom: 50%;" /><img src="https://s1.ax1x.com/2022/09/16/vzcd39.png" alt="formula4" style="zoom: 50%;" /><p>提示:⊕ denotes the concatenation operation</p><p><strong>Procedure Image</strong></p><p><img src="https://s1.ax1x.com/2022/09/16/vzcxuq.png"></p><p><strong>Segmentation Model Learning</strong></p><p>整个流程的算法如下:</p><p><img src="https://s1.ax1x.com/2022/09/16/vzcsHK.png" alt="algorithm"></p><h3 id="Residual-Prototype-Mixture-Models"><a href="#Residual-Prototype-Mixture-Models" class="headerlink" title="Residual Prototype Mixture Models"></a>Residual Prototype Mixture Models</h3><p><img src="https://s1.ax1x.com/2022/09/16/vzcM1s.png" alt="RPPM"></p>]]></content>
<summary type="html"><h1 id="论文阅读-Prototype-Mixture-Models-for-Few-shot-Semantic-Segmentation"><a href="#论文阅读-Prototype-Mixture-Models-for-Few-shot-Semantic-Segm</summary>
<category term="论文阅读" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/"/>
<category term="ECCV" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/ECCV/"/>
<category term="2020" scheme="https://lzl2040.github.io/categories/%E8%AE%BA%E6%96%87%E9%98%85%E8%AF%BB/ECCV/2020/"/>
<category term="Paper Note" scheme="https://lzl2040.github.io/tags/Paper-Note/"/>
<category term="FSS" scheme="https://lzl2040.github.io/tags/FSS/"/>
</entry>
<entry>
<title>算法学习笔记-动态规划</title>
<link href="https://lzl2040.github.io/2022/03/30/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/"/>
<id>https://lzl2040.github.io/2022/03/30/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/</id>
<published>2022-03-30T15:26:06.000Z</published>
<updated>2022-03-30T15:28:05.350Z</updated>
<category term="算法笔记" scheme="https://lzl2040.github.io/categories/%E7%AE%97%E6%B3%95%E7%AC%94%E8%AE%B0/"/>
<category term="算法" scheme="https://lzl2040.github.io/tags/%E7%AE%97%E6%B3%95/"/>
</entry>
<entry>
<title>算法学习笔记-快速幂</title>
<link href="https://lzl2040.github.io/2022/03/27/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%BF%AB%E9%80%9F%E5%B9%82/"/>
<id>https://lzl2040.github.io/2022/03/27/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%BF%AB%E9%80%9F%E5%B9%82/</id>
<published>2022-03-27T13:18:52.000Z</published>
<updated>2022-03-27T13:40:34.174Z</updated>
<content type="html"><![CDATA[<h2 id="引入"><a href="#引入" class="headerlink" title="引入"></a>引入</h2><h2 id="例题"><a href="#例题" class="headerlink" title="例题"></a>例题</h2>]]></content>
<summary type="html"><h2 id="引入"><a href="#引入" class="headerlink" title="引入"></a>引入</h2><h2 id="例题"><a href="#例题" class="headerlink" title="例题"></a>例题</h2></summary>
<category term="算法笔记" scheme="https://lzl2040.github.io/categories/%E7%AE%97%E6%B3%95%E7%AC%94%E8%AE%B0/"/>
<category term="算法" scheme="https://lzl2040.github.io/tags/%E7%AE%97%E6%B3%95/"/>
</entry>
<entry>
<title>2022(美赛)MCM总结</title>
<link href="https://lzl2040.github.io/2022/02/22/2022-%E7%BE%8E%E8%B5%9B-MCM%E6%80%BB%E7%BB%93/"/>
<id>https://lzl2040.github.io/2022/02/22/2022-%E7%BE%8E%E8%B5%9B-MCM%E6%80%BB%E7%BB%93/</id>
<published>2022-02-22T09:01:20.000Z</published>
<updated>2022-09-14T14:34:16.778Z</updated>
<content type="html"><![CDATA[<h1 id="2022美国大学生数学建模-MCM-总结"><a href="#2022美国大学生数学建模-MCM-总结" class="headerlink" title="2022美国大学生数学建模(MCM)总结"></a>2022美国大学生数学建模(MCM)总结</h1><h2 id="时间历程"><a href="#时间历程" class="headerlink" title="时间历程"></a>时间历程</h2><h3 id="2-17日"><a href="#2-17日" class="headerlink" title="2.17日"></a>2.17日</h3><p>买的下午2点的车,偷偷去看了一下我亲爱的女朋友,想死她了,心情还是十分舒畅的~~~~,附上吃饭的一张图片</p><p>然后在娄底站等了将近4个小时的火车,终于等到了。感觉从邵东到冷水江不是很方便,汽车也没有直达的,不然直接就坐汽车了。</p><p>到了夜晚将近8点钟,终于到我队友家了,吃了晚饭,然后养精蓄锐准备明天的比赛。</p><h3 id="2-18日"><a href="#2-18日" class="headerlink" title="2.18日"></a>2.18日</h3><p>当天早上5点就起来了,不过腾飞起的太早了困得不行,然后又睡了一会,到9点正式开始这个比赛。</p><p>中间有个很无语的就是,腾飞定了一个闹钟,半夜把我和宇航哥吵醒了,他自己没醒。</p><p>我们先是开始查找资料,最开始选的是C题,对数据进行了稍微处理后就放弃了,觉得没有想象的那么简单,然后我们选择了B题,是一个规划类的问题。好巧不巧,我们国赛也选的是B题。希望美赛和国赛一样有一个比较好的结果吧。</p><p>选好了题目后,我们遇到了一个十分困难的问题,找数据!!!我们是真不会找数据,不过好在老师给选一个题目的建了一个群,我们那个群里的人都共享数据了。看了其他组找数据的速度,我感觉自己就是个菜逼。离谱的是,他们给了我一个网址,我也不知道数据在哪。笑死。还好最后把该找的数据都找到了。</p><p>第一问的数据也是找到夜晚,我倒是没怎么找数据,有些都是宇航哥找的。夜晚对第一问进行了建模,腾飞还说今天把第一问做完,我是比较害怕的,不想在第一天就熬夜,不过实际上只把第一问做完了,因为他熬不住了,笑死。这一天是凌晨1点多左右睡的。</p><h3 id="2-19日"><a href="#2-19日" class="headerlink" title="2.19日"></a>2.19日</h3><p>这一天主要解决了第一问的第二三小问,话说这个第一问就真的劝退了很多人,第一问就有三小问,真的离谱。还好我们的速度还是比较快的,中间经过腾飞不断的微操,我们模型的结果应该也是比较客观的。这一天也不是很累,编程的话按照他写的思路来就好了。只要自己不犯病,应该都不会有很大的问题。这天我们12点多就睡了,也是腾飞熬不住了。</p><h3 id="2-20日"><a href="#2-20日" class="headerlink" title="2.20日"></a>2.20日</h3><p>时间比较紧了,这天我们早上6点多就起来了,开始干这个题目。</p><p>腾飞已经把第二问思路写好了,不过遇到一个麻烦,因为第二问是一个非线性规划的问题,而且他给的不等式的约束条件太过严苛,最后跑不出一个最优解来。</p><p>我用蒙特卡洛算法跑了1000000次,取的随机数没有一个满足条件的,最后用遗传算法稍微有了一点结果,但感觉也不对,希望老师不要发现这个情况。我们不能拘泥于这一个题目,所以结果暂时就这样,之后腾飞就开始写第三问的思路。</p><p>事实上,在做完了第一问之后,其他的题目也就没有这么难了,第三问也是在第一问模型的基础上做了一些修改,等他模型写完,我稍微改一下第三问的结果就出来了。</p><p>最后第四问,就是一个灵敏度分析的问题,我们改了几个参数,然后跑第一问的模型,最后得到了我们最终的结果。至此,我的编程任务差不多结束了。这个时候还比较早的,大概是下午两三点左右。之后就开始着手论文的书写。</p><p>这天夜晚我还是比较轻松的,找一些参考文献什么的,没有什么任务很重的事情。大概在1点钟,我们就睡觉了。</p><h3 id="2-21日"><a href="#2-21日" class="headerlink" title="2.21日"></a>2.21日</h3><p>这一天是最累的一天了,其实到下午的时候我们的论文差不多已经完成了,主体部分的英文也都翻译成了英文,应该也没啥语法错误。</p><p>之后就是噩梦的开始了。我们大概从夜晚11点左右开始翻译摘要,一直到凌晨5点,修改了将近6个小时,终于把这个该死的摘要改完了。主要是论文摘要不能超过一页,但是中文翻译成英文后行数会变多,我们就不得不一直压缩中文,最后终于搞好了。</p><p>最后的部分结果截图:</p><p><img src="https://gitee.com/lzl2040/pic-store/raw/master/blog/6/MCM.png" alt="MCM.png (839×693) (gitee.com)"></p><h3 id="2-22日"><a href="#2-22日" class="headerlink" title="2.22日"></a>2.22日</h3><p>一觉睡到中午11点。</p><h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>这次美赛,让我发现了自己的不足,编程能力还是有待提高的。如果自己编程能力再强一点,可能那个非线性规划就能解决了。</p><p>收获:</p><ul><li>锻炼了自己的编程能力</li><li>对matlab的使用更加熟练</li><li>可能会获得一个比较不错的奖(4月30日)</li></ul><p>反思:</p><ul><li>自己应该多思考一点,不能就按照别人的想法来做</li><li>编程能力有进一步提高</li></ul>]]></content>
<summary type="html"><h1 id="2022美国大学生数学建模-MCM-总结"><a href="#2022美国大学生数学建模-MCM-总结" class="headerlink" title="2022美国大学生数学建模(MCM)总结"></a>2022美国大学生数学建模(MCM)总结</h1><</summary>
<category term="总结" scheme="https://lzl2040.github.io/categories/%E6%80%BB%E7%BB%93/"/>
<category term="matlab" scheme="https://lzl2040.github.io/tags/matlab/"/>
<category term="MCM" scheme="https://lzl2040.github.io/tags/MCM/"/>
</entry>
<entry>
<title>算法学习笔记-并查集</title>
<link href="https://lzl2040.github.io/2022/02/09/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%B9%B6%E6%9F%A5%E9%9B%86/"/>
<id>https://lzl2040.github.io/2022/02/09/%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E5%B9%B6%E6%9F%A5%E9%9B%86/</id>
<published>2022-02-09T12:55:10.000Z</published>
<updated>2022-09-14T14:35:53.631Z</updated>
<content type="html"><![CDATA[<h2 id="引入"><a href="#引入" class="headerlink" title="引入"></a>引入</h2><p>假设这么一种场景:突然有一天,你发现你和你的同桌原来有着很薄的亲戚关系,很久很久以前你们有一个共同的祖先,那么要怎么判断你和他的家族其实是同一个祖先了?</p><p>这个时候我们肯定想到的是不断往回推,即:我->我的爸爸->我的爷爷->我的爷爷的爸爸…一直往前推,直到出现一个交集,那个就是共同的祖先。</p><p>这个其实就是一种并查集的思想,合并两个集合,就是要找到一个共同的祖先。(这个祖先也可以自己设置)</p><p>从此以后,你们就是一家人了。</p><h2 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h2><p>并查集其实是一种树形的数据结构,它主要有两种操作,查找(Find)和合并(Union)。查找就类似于追溯自己的祖先,合并就相当于将两个家族合并,祭拜同一个祖先。这里一个家族就相当于一个集合,并查集主要是处理<strong>集合问题</strong>。</p><p>并查集的用途:</p><ul><li>解决元素分组的问题</li><li>合并不相交的集合</li><li>判断图中是否含有环</li><li>判断连通区域个数</li></ul><h2 id="算法介绍"><a href="#算法介绍" class="headerlink" title="算法介绍"></a>算法介绍</h2><h3 id="查找-Find"><a href="#查找-Find" class="headerlink" title="查找-Find"></a>查找-Find</h3><p><img src="https://s1.ax1x.com/2022/09/14/vxmXFA.md.png"></p><p>假如我们要根据F找到它的祖先,我们先是找到它的父节点C,然后再找到C的父节点A,此时它就是F的祖先了。</p><p>算法怎么实现呢?可以定义一个数组,表示当前节点的父节点是谁,初始化都为本身节点,然后不断往回推就行。</p><p>代码如下:</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//递归版本</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">find</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> parent[])</span></span>{</span><br><span class="line"><span class="keyword">if</span>(parent[x] == x){</span><br><span class="line"><span class="keyword">return</span> x;</span><br><span class="line">}</span><br><span class="line"><span class="keyword">return</span> find(parent[x]);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//循环版本</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">find2</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> parent[])</span></span>{</span><br><span class="line"> <span class="keyword">while</span>(x != parent[x]){</span><br><span class="line"> x = parent[x];</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> x;</span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure><h3 id="合并-Union"><a href="#合并-Union" class="headerlink" title="合并-Union"></a>合并-Union</h3><p>另一段集合</p><p><img src="https://s1.ax1x.com/2022/09/14/vxmLod.md.png"></p><p>假设A集合也是在集合当中,即节点A的父节点其实是G节点,这个时候我们就需要合并这两个集合了。</p><p>这个其实比较简单,我们先找到A集合的根节点,然后找到另外一个集合的根节点G,然后设置A集合的父节点为G即可。</p><p>代码如下:</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">union</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y,<span class="keyword">int</span> parent[])</span></span>{</span><br><span class="line"><span class="keyword">int</span> parent_x = find(x);</span><br><span class="line"> <span class="keyword">int</span> parent_y = find(y);</span><br><span class="line"> parent[parent_x] = parent_y;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>合并后的结构如下:</p><p><img src="https://s1.ax1x.com/2022/09/14/vxmjJI.md.png"></p><h3 id="路径压缩"><a href="#路径压缩" class="headerlink" title="路径压缩"></a>路径压缩</h3><p>我们发现,当树的高度很高时,我们查询的效率就比较慢,故要进行路径压缩。</p><p>我们可以将每个节点的父节点都指向根节点,这样就十分方便了。</p><p>代码优化后的情形:</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">find</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> parent[])</span></span>{</span><br><span class="line"><span class="keyword">if</span>(parent[x] == x){</span><br><span class="line"><span class="keyword">return</span> x;</span><br><span class="line">}</span><br><span class="line"> parent[x] = find(parent[x]);</span><br><span class="line"><span class="keyword">return</span> parent[x];</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="例题"><a href="#例题" class="headerlink" title="例题"></a>例题</h2><h3 id="七段码"><a href="#七段码" class="headerlink" title="七段码"></a>七段码</h3><h4 id="描述"><a href="#描述" class="headerlink" title="描述"></a>描述</h4><p>小蓝要用七段码数码管来表示一种特殊的文字。</p><p><img src="https://doc.shiyanlou.com/courses/uid1580206-20210312-1615527941739"></p><p>上图给出了七段码数码管的一个图示,数码管中一共有 7 段可以发光的二 极管,分别标记为 <em>a</em>,<em>b</em>,<em>c</em>,<em>d</em>,<em>e</em>,<em>f</em>,<em>g</em>。</p><p>小蓝要选择一部分二极管(至少要有一个)发光来表达字符。在设计字符 的表达时,要求所有发光的二极管是连成一片的。</p><p>例如:<em>b</em> 发光,其他二极管不发光可以用来表达一种字符。</p><p>例如 <em>c</em> 发光,其他二极管不发光可以用来表达一种字符。这种方案与上 一行的方案可以用来表示不同的字符,尽管看上去比较相似。</p><p>例如:<em>a</em>,<em>b</em>,<em>c</em>,<em>d</em>,<em>e</em> 发光, <em>f</em>,<em>g</em> 不发光可以用来表达一种字符。</p><p>例如:<em>b</em>,<em>f</em> 发光,其他二极管不发光则不能用来表达一种字符,因为发光 的二极管没有连成一片。</p><p>请问,小蓝可以用七段码数码管表达多少种不同的字符?</p><h4 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> map[][] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">10</span>][<span class="number">10</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> parent[] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">10</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> vis[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">10</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> res = <span class="number">0</span>;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> initMap();</span><br><span class="line"> dfs(<span class="number">1</span>);</span><br><span class="line"> System.out.println(res);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">initMap</span><span class="params">()</span></span>{</span><br><span class="line"> add(<span class="number">1</span>,<span class="number">2</span>); add(<span class="number">1</span>,<span class="number">6</span>);</span><br><span class="line"> add(<span class="number">2</span>,<span class="number">3</span>); add(<span class="number">2</span>,<span class="number">7</span>);</span><br><span class="line"> add(<span class="number">3</span>,<span class="number">4</span>); add(<span class="number">3</span>,<span class="number">7</span>);</span><br><span class="line"> add(<span class="number">4</span>,<span class="number">5</span>); add(<span class="number">5</span>,<span class="number">6</span>); add(<span class="number">5</span>,<span class="number">7</span>);</span><br><span class="line"> add(<span class="number">6</span>,<span class="number">7</span>); add(<span class="number">6</span>,<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">add</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>{</span><br><span class="line"> map[x][y] = map[y][x] = <span class="number">1</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">find</span><span class="params">(<span class="keyword">int</span> x)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(parent[x] == x){</span><br><span class="line"> <span class="keyword">return</span> x;</span><br><span class="line"> }</span><br><span class="line"> parent[x] = find(parent[x]);</span><br><span class="line"> <span class="keyword">return</span> parent[x];</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(x >= <span class="number">8</span>){</span><br><span class="line"> <span class="keyword">if</span>(check()){</span><br><span class="line"> res++;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//数码管被选中</span></span><br><span class="line"> vis[x] = <span class="keyword">true</span>;</span><br><span class="line"> dfs(x+<span class="number">1</span>);</span><br><span class="line"> vis[x] = <span class="keyword">false</span>;</span><br><span class="line"> <span class="comment">//该数码管不被选中</span></span><br><span class="line"> dfs(x+<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">boolean</span> <span class="title">check</span><span class="params">()</span></span>{</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i <= <span class="number">7</span>;i++){</span><br><span class="line"> parent[i] = i;</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//合并</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i <= <span class="number">7</span>;i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">1</span>;j <= <span class="number">7</span>;j++){</span><br><span class="line"> <span class="keyword">if</span>(vis[i] && vis[j] && map[i][j] != <span class="number">0</span>){</span><br><span class="line"> parent[find(j)] = find(i);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//找根的个数,发光二极管的连通区域个数</span></span><br><span class="line"> <span class="keyword">int</span> count = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i <= <span class="number">7</span>;i++){</span><br><span class="line"> <span class="keyword">if</span>(parent[i] == i && vis[i]){</span><br><span class="line"> count++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(count == <span class="number">1</span>){</span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><h2 id="引入"><a href="#引入" class="headerlink" title="引入"></a>引入</h2><p>假设这么一种场景:突然有一天,你发现你和你的同桌原来有着很薄的亲戚关系,很久很久以前你们有一个共同的祖先,那么要怎么判断你和他的家族其实是同</summary>
<category term="算法笔记" scheme="https://lzl2040.github.io/categories/%E7%AE%97%E6%B3%95%E7%AC%94%E8%AE%B0/"/>
<category term="算法" scheme="https://lzl2040.github.io/tags/%E7%AE%97%E6%B3%95/"/>
</entry>
<entry>
<title>matlab编程笔记</title>
<link href="https://lzl2040.github.io/2022/01/27/matlab%E7%BC%96%E7%A8%8B%E7%AC%94%E8%AE%B0/"/>
<id>https://lzl2040.github.io/2022/01/27/matlab%E7%BC%96%E7%A8%8B%E7%AC%94%E8%AE%B0/</id>
<published>2022-01-27T09:39:03.000Z</published>
<updated>2022-09-14T14:32:51.126Z</updated>
<content type="html"><![CDATA[<h1 id="美赛期间使用matlab的一些笔记"><a href="#美赛期间使用matlab的一些笔记" class="headerlink" title="美赛期间使用matlab的一些笔记"></a>美赛期间使用matlab的一些笔记</h1><h3 id="字符串比较"><a href="#字符串比较" class="headerlink" title="字符串比较"></a><strong>字符串比较</strong></h3><p> strcmp函数</p><h3 id="cell类型转换为字符串"><a href="#cell类型转换为字符串" class="headerlink" title="cell类型转换为字符串"></a><strong>cell类型转换为字符串</strong></h3><p> txt{i},txt为cell数组</p><h3 id="关于数组的下标引用"><a href="#关于数组的下标引用" class="headerlink" title="关于数组的下标引用"></a><strong>关于数组的下标引用</strong></h3><p>a(i,:) 表示第i行</p><p>a(:,i) 表示第i列</p><p>a(i:j,:) 表示第i行到第j列</p><h3 id="将数据写入文件"><a href="#将数据写入文件" class="headerlink" title="将数据写入文件"></a><strong>将数据写入文件</strong></h3><p>xlswrite<br>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">%% 写入字符串类型或者cell类型,比如日期,字符串等</span></span><br><span class="line">txt2 = {<span class="string">"经度"</span>,<span class="string">"纬度"</span>};</span><br><span class="line">xlswrite(<span class="string">'position_data.xlsx'</span>,txt2);<span class="comment">%txt2为字符类型的</span></span><br><span class="line">datas_position = [<span class="number">1</span> <span class="number">2</span> <span class="number">3</span>;<span class="number">2</span> <span class="number">3</span> <span class="number">5</span>;<span class="number">5</span> <span class="number">6</span> <span class="number">7</span>];</span><br><span class="line">xlswrite(<span class="string">'position_data.xlsx'</span>,datas_position,<span class="string">'C2:E4'</span>);<span class="comment">% C2:E4是写入的位置</span></span><br></pre></td></tr></table></figure><h3 id="生成字符数组"><a href="#生成字符数组" class="headerlink" title="生成字符数组"></a><strong>生成字符数组</strong></h3><p>使用函数strings</p><p>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">positive = strings(<span class="number">3</span>,<span class="number">4</span>)</span><br></pre></td></tr></table></figure><h3 id="对日期的计算"><a href="#对日期的计算" class="headerlink" title="对日期的计算"></a><strong>对日期的计算</strong></h3><p>使用datenum函数,它会将日期转换为天数(具体起始时间我也不是很清楚)</p><p>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">format = <span class="string">'yyyy/mm/dd'</span>;<span class="comment">%它的格式</span></span><br><span class="line">datenum(<span class="string">'2020/3/4'</span>,format) - datenum(<span class="string">'2020/3/1'</span>,format)</span><br></pre></td></tr></table></figure><h3 id="排序问题"><a href="#排序问题" class="headerlink" title="排序问题"></a><strong>排序问题</strong></h3><p>主要是涉及有多个数据项的时候,即我根据某一个数据项进行排序后,其他的数据项也应该按照我这个顺序来,</p><p>使用sortrows函数</p><p>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">fit_data = [time_interval position];<span class="comment">%14行3列</span></span><br><span class="line">fit_data = <span class="built_in">sortrows</span>(fit_data,<span class="number">1</span>);<span class="comment">%根据第一列的数据进行升序排序,其他列跟着变</span></span><br></pre></td></tr></table></figure><h3 id="字符串的拼接"><a href="#字符串的拼接" class="headerlink" title="字符串的拼接"></a><strong>字符串的拼接</strong></h3><p>使用函数strcat或者利用字符数组的性质。</p><p>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">a = <span class="string">'abc'</span>;</span><br><span class="line">b = <span class="string">'123'</span>;</span><br><span class="line">c = strcat(a,b);</span><br><span class="line">d = [a,b];</span><br></pre></td></tr></table></figure><p>若是有数字,可用mat2str将数字先转换为函数,如果在strcat直接使用数字的话,数字会被解析为ASCII码对应的字符。</p><p>示例:</p><figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">c = strcat(<span class="string">'A'</span>,mat2str(<span class="number">1</span>))</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><h1 id="美赛期间使用matlab的一些笔记"><a href="#美赛期间使用matlab的一些笔记" class="headerlink" title="美赛期间使用matlab的一些笔记"></a>美赛期间使用matlab的一些笔记</h1><h3 id="字符串比较</summary>
<category term="笔记" scheme="https://lzl2040.github.io/categories/%E7%AC%94%E8%AE%B0/"/>
<category term="matlab" scheme="https://lzl2040.github.io/tags/matlab/"/>
</entry>
<entry>
<title>蓝桥杯刷题题解</title>
<link href="https://lzl2040.github.io/2022/01/27/%E8%93%9D%E6%A1%A5%E6%9D%AF%E5%88%B7%E9%A2%98%E9%A2%98%E8%A7%A3/"/>
<id>https://lzl2040.github.io/2022/01/27/%E8%93%9D%E6%A1%A5%E6%9D%AF%E5%88%B7%E9%A2%98%E9%A2%98%E8%A7%A3/</id>
<published>2022-01-27T09:38:38.000Z</published>
<updated>2022-09-14T14:32:34.758Z</updated>
<content type="html"><![CDATA[<p>[toc]</p><h1 id="DFS算法"><a href="#DFS算法" class="headerlink" title="DFS算法"></a>DFS算法</h1><h2 id="迷宫-2017年省赛"><a href="#迷宫-2017年省赛" class="headerlink" title="迷宫(2017年省赛)"></a>迷宫(2017年省赛)</h2><h3 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h3><p>X 星球的一处迷宫游乐场建在某个小山坡上。它是由 10×10 相互连通的小房间组成的。</p><p>房间的地板上写着一个很大的字母。我们假设玩家是面朝上坡的方向站立,则:</p><ul><li><em>L</em> 表示走到左边的房间,</li><li><em>R</em> 表示走到右边的房间,</li><li><em>U</em> 表示走到上坡方向的房间,</li><li><em>D</em> 表示走到下坡方向的房间。</li></ul><p>X 星球的居民有点懒,不愿意费力思考。他们更喜欢玩运气类的游戏。这个游戏也是如此!</p><p>开始的时候,直升机把 100 名玩家放入一个个小房间内。玩家一定要按照地上的字母移动。</p><p>迷宫地图如下:</p><p>UDDLUULRUL<br>UURLLLRRRU<br>RRUURLDLRD<br>RUDDDDUUUU<br>URUDLLRRUU<br>DURLRLDLRL<br>ULLURLLRDU<br>RDLULLRDDD<br>UUDDUDUDLL<br>ULRDLUURRR</p><p>请你计算一下,最后,有多少玩家会走出迷宫,而不是在里边兜圈子?</p><h3 id="解题思路"><a href="#解题思路" class="headerlink" title="解题思路"></a>解题思路</h3><p>DFS,每个点都要作为起点一次</p><h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> vis[][] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">11</span>][<span class="number">11</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> res = <span class="keyword">false</span>;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">char</span> maze[][] = <span class="keyword">new</span> <span class="keyword">char</span>[<span class="number">11</span>][<span class="number">11</span>];</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">10</span>; i++){</span><br><span class="line"> String line = scan.nextLine();</span><br><span class="line"> maze[i] = line.toCharArray();</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">10</span>;i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;j < <span class="number">10</span>;j++){</span><br><span class="line"> vis = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">11</span>][<span class="number">11</span>];</span><br><span class="line"> res = <span class="keyword">false</span>;</span><br><span class="line"> dfs(i,j);</span><br><span class="line"> <span class="keyword">if</span>(res){</span><br><span class="line"> counts++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> scan.close();</span><br><span class="line"> System.out.println(counts);</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(x == -<span class="number">1</span> || x == <span class="number">10</span> || y == -<span class="number">1</span> || y == <span class="number">10</span>){</span><br><span class="line"> res = <span class="keyword">true</span>;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(vis[x][y]){</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> vis[x][y]=<span class="keyword">true</span>;</span><br><span class="line"> <span class="keyword">if</span>(maze[x][y] == <span class="string">'U'</span>){</span><br><span class="line"> dfs(x-<span class="number">1</span>,y);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(maze[x][y] == <span class="string">'D'</span>){</span><br><span class="line"> dfs(x+<span class="number">1</span>,y);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(maze[x][y] == <span class="string">'L'</span>){</span><br><span class="line"> dfs(x,y-<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(maze[x][y] == <span class="string">'R'</span>){</span><br><span class="line"> dfs(x,y+<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="方格-2017年省赛"><a href="#方格-2017年省赛" class="headerlink" title="方格(2017年省赛)"></a>方格(2017年省赛)</h2><h3 id="题目描述-1"><a href="#题目描述-1" class="headerlink" title="题目描述"></a>题目描述</h3><p>6x6的方格,沿着格子的边线剪开成两部分。 要求这两部分的形状完全相同。</p><p>如下就是三种可行的分割法。</p><p><img src="https://doc.shiyanlou.com/courses/uid1580206-20210317-1615964222859" alt="图片描述"></p><p><img src="https://doc.shiyanlou.com/courses/uid1580206-20210317-1615964217192" alt="图片描述"></p><p><img src="https://doc.shiyanlou.com/courses/uid1580206-20210317-1615964210676" alt="图片描述"></p><p>试计算: 包括这 33 种分法在内,一共有多少种不同的分割方法。 注意:旋转对称的属于同一种分割法。</p><h3 id="解题思路-1"><a href="#解题思路-1" class="headerlink" title="解题思路"></a>解题思路</h3><p>每次从中心点(3,3)开始遍历,到达边界即说明已经分割完毕(我也不是很理解)</p><h3 id="代码-1"><a href="#代码-1" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> dirX[] = <span class="keyword">new</span> <span class="keyword">int</span>[]{<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>,-<span class="number">1</span>};</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> dirY[] = <span class="keyword">new</span> <span class="keyword">int</span>[]{<span class="number">1</span>,-<span class="number">1</span>,<span class="number">0</span>,<span class="number">0</span>};</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span>[][] maze = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">7</span>][<span class="number">7</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> maze[<span class="number">3</span>][<span class="number">3</span>]=<span class="number">1</span>;</span><br><span class="line"> dfs(<span class="number">3</span>,<span class="number">3</span>);</span><br><span class="line"> System.out.print(counts/<span class="number">4</span>);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(x == <span class="number">0</span> || y == <span class="number">0</span> || x == <span class="number">6</span> || y == <span class="number">6</span>){</span><br><span class="line"> counts++;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">4</span>;i++){</span><br><span class="line"> <span class="keyword">int</span> nx = dirX[i] + x;</span><br><span class="line"> <span class="keyword">int</span> ny = dirY[i] + y;</span><br><span class="line"> <span class="keyword">if</span>(maze[nx][ny] == <span class="number">0</span>){</span><br><span class="line"> maze[nx][ny] = <span class="number">1</span>;</span><br><span class="line"> maze[<span class="number">6</span>-nx][<span class="number">6</span>-ny]=<span class="number">1</span>;</span><br><span class="line"> dfs(nx,ny);</span><br><span class="line"> maze[nx][ny] = <span class="number">0</span>;</span><br><span class="line"> maze[<span class="number">6</span>-nx][<span class="number">6</span>-ny]=<span class="number">0</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="正则问题-2017年省赛"><a href="#正则问题-2017年省赛" class="headerlink" title="正则问题(2017年省赛)"></a>正则问题(2017年省赛)</h2><h3 id="题目描述-2"><a href="#题目描述-2" class="headerlink" title="题目描述"></a>题目描述</h3><p>考虑一种简单的正则表达式:</p><p>只由 x ( ) | 组成的正则表达式。</p><p>小明想求出这个正则表达式能接受的最长字符串的长度。</p><p>例如 ((xx|xxx)x|(x|xx))xx 能接受的最长字符串是: xxxxxx,长度是 6。</p><h3 id="解题思路-2"><a href="#解题思路-2" class="headerlink" title="解题思路"></a>解题思路</h3><p>深度优先搜索DFS,注意分隔符’(‘,’)’以及|这几种情况。</p><h3 id="代码-2"><a href="#代码-2" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> index = <span class="number">0</span>,len;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> String s = scan.nextLine();</span><br><span class="line"> <span class="keyword">char</span> chs[] = s.toCharArray();</span><br><span class="line"> len = s.length();</span><br><span class="line"> System.out.println(dfs(chs));</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">dfs</span><span class="params">(<span class="keyword">char</span> chs[])</span></span>{</span><br><span class="line"> <span class="keyword">int</span> max = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">int</span> temp = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">while</span>(index < len){</span><br><span class="line"> <span class="keyword">if</span>(chs[index] == <span class="string">'('</span>){</span><br><span class="line"> index++;</span><br><span class="line"> temp += dfs(chs);</span><br><span class="line"> }<span class="keyword">else</span> <span class="keyword">if</span>(chs[index] == <span class="string">')'</span>){</span><br><span class="line"> index++;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }<span class="keyword">else</span> <span class="keyword">if</span>(chs[index] == <span class="string">'|'</span>){</span><br><span class="line"> <span class="keyword">if</span>(temp > max){</span><br><span class="line"> max = temp;</span><br><span class="line"> }</span><br><span class="line"> index++;</span><br><span class="line"> temp = <span class="number">0</span>;</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> index++;</span><br><span class="line"> temp++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(temp > max){</span><br><span class="line"> max = temp;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> max;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="受伤的皇后"><a href="#受伤的皇后" class="headerlink" title="受伤的皇后"></a>受伤的皇后</h2><h3 id="题目描述-3"><a href="#题目描述-3" class="headerlink" title="题目描述"></a>题目描述</h3><p>有一个 <em>n</em>×<em>n</em> 的国际象棋棋盘(<em>n</em> 行 n 列的方格图),请在棋盘中摆放 <em>n</em> 个受伤的国际象棋皇后,要求:</p><ol><li>任何两个皇后不在同一行。</li><li>任何两个皇后不在同一列。</li><li>如果两个皇后在同一条 45 度角的斜线上,这两个皇后之间行号的差值至少为 3 。</li></ol><p>请问一共有多少种摆放方案。</p><h3 id="输入描述"><a href="#输入描述" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入的第一行包含一个整数 <em>n</em>。</p><p>其中,1≤<em>n</em>≤10。</p><h3 id="输出描述"><a href="#输出描述" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出一个整数,表示答案。</p><h3 id="题目思路"><a href="#题目思路" class="headerlink" title="题目思路"></a>题目思路</h3><p>求方案数目,很容易想到深度优先搜索,不过这里要<strong>注意对角线情况的标记</strong>,这里我们进行了状态压缩。</p><p>首先注意每一行都要有一个皇后,这就决定了在<strong>深度遍历时只要行数递增</strong>即可,然后在每一行遍历每一列,判断该格子是否满足摆放要求。满足要求则进入下一行,直到皇后数等于n为止。</p><p>关于判断是否满足摆放要求,这里进行了类似于状态压缩的方法,比如:</p><ul><li>如果第一列已经被遍历了,那么col[i]就等于true,说明这一列已经被遍历了,而不是这一列的所有元素都标记为true</li><li>对于对角线的情况,我们研究它的直线方程,对于正对角线,它的直线方程一般是:x - y = m,那么我们就用这个m来指代这一条直线上的点的情况,但是要注意x - y可能是负数,所以要改为x - y + n;相似的,对于反对角线,它的直线方程一般是:x+y = m,那么我们就用这个m来指代这一条直线上的点的情况。(x是行的位置,y是列的位置)</li></ul><h3 id="代码-3"><a href="#代码-3" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> col[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">11</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> duijiao[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">11</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> duijiao2[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">11</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> n;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> n = scan.nextInt();</span><br><span class="line"> <span class="comment">//深度优先搜索</span></span><br><span class="line"> dfs(<span class="number">0</span>);</span><br><span class="line"> System.out.println(counts);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> step)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(step == n){</span><br><span class="line"> counts++;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < n; i ++){</span><br><span class="line"> <span class="keyword">if</span>(!col[i] && !duijiao[step - i + n] && !duijiao2[step + i]){</span><br><span class="line"> col[i] = <span class="keyword">true</span>;</span><br><span class="line"> duijiao[step - i + n] = <span class="keyword">true</span>;</span><br><span class="line"> duijiao2[step + i] = <span class="keyword">true</span>;</span><br><span class="line"> dfs(step + <span class="number">1</span>);</span><br><span class="line"> col[i] = <span class="keyword">false</span>;</span><br><span class="line"> duijiao[step - i + n] = <span class="keyword">false</span>;</span><br><span class="line"> duijiao2[step + i] = <span class="keyword">false</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="灌溉-2021模拟"><a href="#灌溉-2021模拟" class="headerlink" title="灌溉(2021模拟)"></a>灌溉(2021模拟)</h2><h3 id="题目描述-4"><a href="#题目描述-4" class="headerlink" title="题目描述"></a>题目描述</h3><p>小蓝负责花园的灌溉工作。</p><p>花园可以看成一个 n 行 m列的方格图形。中间有一部分位置上安装有出水管。</p><p>小蓝可以控制一个按钮同时打开所有的出水管,打开时,有出水管的位置可以被认为已经灌溉好。</p><p>每经过一分钟,水就会向四面扩展一个方格,被扩展到的方格可以被认为已经灌溉好。即如果前一分钟某一个方格被灌溉好,则下一分钟它上下左右的四个方格也被灌溉好。</p><p>给定花园水管的位置,请问 <em>k</em> 分钟后,有多少个方格被灌溉好?</p><h3 id="输入描述-1"><a href="#输入描述-1" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入的第一行包含两个整数 <em>n</em>,<em>m</em>。</p><p>第二行包含一个整数 <em>t</em>,表示出水管的数量。</p><p>接下来 <em>t</em> 行描述出水管的位置,其中第 <em>i</em> 行包含两个数 <em>r</em>,<em>c</em> 表示第 <em>r</em> 行第 c列有一个排水管。</p><p>接下来一行包含一个整数 k。</p><p>其中,1≤<em>n</em>,<em>m</em>≤100,1≤<em>t</em>≤10,1≤<em>k</em>≤100。</p><h3 id="输出描述-1"><a href="#输出描述-1" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出一个整数,表示答案。</p><h3 id="思路"><a href="#思路" class="headerlink" title="思路"></a>思路</h3><p>典型的深度优先搜索。</p><h3 id="代码-4"><a href="#代码-4" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="keyword">import</span> java.util.LinkedList;</span><br><span class="line"><span class="keyword">import</span> java.util.Queue;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> line[] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">11</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> column[] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">11</span>]; </span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> vis[][] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">101</span>][<span class="number">101</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> dirX[] = <span class="keyword">new</span> <span class="keyword">int</span>[]{<span class="number">0</span>,<span class="number">0</span>,-<span class="number">1</span>,<span class="number">1</span>};</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> dirY[] = <span class="keyword">new</span> <span class="keyword">int</span>[]{-<span class="number">1</span>,<span class="number">1</span>,<span class="number">0</span>,<span class="number">0</span>};</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> m,n;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> n = scan.nextInt();</span><br><span class="line"> m = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> t = scan.nextInt();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i < t;i++){</span><br><span class="line"> line[i] = scan.nextInt();</span><br><span class="line"> column[i] = scan.nextInt();</span><br><span class="line"> vis[line[i]-<span class="number">1</span>][column[i]-<span class="number">1</span>] = <span class="keyword">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">int</span> k = scan.nextInt();</span><br><span class="line"> <span class="comment">//dfs</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < t;i++){</span><br><span class="line"> dfs(line[i]-<span class="number">1</span>,column[i]-<span class="number">1</span>,k);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < n;i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>; j < m;j++){</span><br><span class="line"> <span class="keyword">if</span>(vis[i][j]){</span><br><span class="line"> counts++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> System.out.println(counts);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y,<span class="keyword">int</span> k)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(k == <span class="number">0</span>){</span><br><span class="line"> vis[x][y] = <span class="keyword">true</span>;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> vis[x][y] = <span class="keyword">true</span>;</span><br><span class="line"> <span class="comment">//四个方向</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i < <span class="number">4</span>;i++){</span><br><span class="line"> <span class="keyword">int</span> nx = x + dirX[i];</span><br><span class="line"> <span class="keyword">int</span> ny = y + dirY[i];</span><br><span class="line"> <span class="keyword">if</span>(nx >=<span class="number">0</span> && nx < n && ny >=<span class="number">0</span> && ny < m){</span><br><span class="line"> dfs(nx,ny,k-<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="排列小球-2021年模拟"><a href="#排列小球-2021年模拟" class="headerlink" title="排列小球(2021年模拟)"></a>排列小球(2021年模拟)</h2><h3 id="题目描述-5"><a href="#题目描述-5" class="headerlink" title="题目描述"></a>题目描述</h3><p>小蓝有黄绿蓝三种颜色的小球,分别为 R,G,B 个。同样颜色的小球没有区别。</p><p>小蓝将这些小球从左到右排成一排,排完后,将最左边的连续同色小球个数记为 t1,将接下来的连续小球个数记为 t2,以此类推直到最右边的小球。</p><p>请问,总共有多少总摆放小球的方案,使得t1,t2,⋯ 为严格单调递增序列,即 t1≤t2≤t3≤⋯。</p><h3 id="输入描述-2"><a href="#输入描述-2" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入一行包含三个整数R,G,B。</p><p>其中,0≤R,G,B≤50。。</p><h3 id="输出描述-2"><a href="#输出描述-2" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出一个整数,表示答案。</p><h3 id="思路-1"><a href="#思路-1" class="headerlink" title="思路"></a>思路</h3><p>关于严格单调递增,应该是t1 < t2 < t3没有等号的。然后这就是一个典型的深度优先搜索,难点在于怎么进行深度遍历。</p><p>我们可以在进行深度遍历的时候提供一个状态量,用来记录上一次的小球是哪一种颜色,然后在当前遍历中判断所选的球是否跟上一次选择的颜色一样,如果一样则跳过,不一样则再递归遍历。</p><p>在遍历的同时,如何判断递归退出并且方案数目增加呢?我们可以用球的总数是否为0来判断,每次深度遍历球的总数都要减去当前选择的球数,同时注意下一次选择的球数要增加,因为是递增的。</p><h3 id="代码-5"><a href="#代码-5" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> color[] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">4</span>];</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> <span class="keyword">int</span> sum = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">3</span>;i++){</span><br><span class="line"> color[i] = scan.nextInt();</span><br><span class="line"> sum += color[i];</span><br><span class="line"> }</span><br><span class="line"> dfs(sum,-<span class="number">1</span>,<span class="number">0</span>);</span><br><span class="line"> System.out.println(counts);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> sum,<span class="keyword">int</span> pre,<span class="keyword">int</span> next)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(sum == <span class="number">0</span>){</span><br><span class="line"> counts++;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">3</span>;i++){</span><br><span class="line"> <span class="keyword">if</span>(i == pre){</span><br><span class="line"> <span class="keyword">continue</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = next + <span class="number">1</span>;j <= color[i];j++){</span><br><span class="line"> color[i] -=j;</span><br><span class="line"> <span class="keyword">if</span>(sum >= j){</span><br><span class="line"> dfs(sum - j,i,j);</span><br><span class="line"> }</span><br><span class="line"> color[i] +=j;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="全球变暖-2018省赛"><a href="#全球变暖-2018省赛" class="headerlink" title="全球变暖(2018省赛)"></a>全球变暖(2018省赛)</h2><h3 id="题目描述-6"><a href="#题目描述-6" class="headerlink" title="题目描述"></a>题目描述</h3><p>你有一张某海域 NxN 像素的照片,”.”表示海洋、”#”表示陆地,如下所示:</p><p>…….</p><p>.##….</p><p>.##….</p><p>….##.</p><p>..####.</p><p>…###.</p><p>…….</p><p>其中”上下左右”四个方向上连在一起的一片陆地组成一座岛屿。例如上图就有 2 座岛屿。</p><p>由于全球变暖导致了海面上升,科学家预测未来几十年,岛屿边缘一个像素的范围会被海水淹没。具体来说如果一块陆地像素与海洋相邻(上下左右四个相邻像素中有海洋),它就会被淹没。</p><p>例如上图中的海域未来会变成如下样子:</p><p>…….</p><p>…….</p><p>…….</p><p>…….</p><p>….#..</p><p>…….</p><p>…….</p><p>请你计算:依照科学家的预测,照片中有多少岛屿会被完全淹没。</p><h3 id="输入描述-3"><a href="#输入描述-3" class="headerlink" title="输入描述"></a>输入描述</h3><p>第一行包含一个整数 <em>N</em> (1≤<em>N</em>≤1000)。</p><p>以下 <em>N</em> 行 <em>N</em> 列代表一张海域照片。</p><p>照片保证第 1 行、第 1 列、第 <em>N</em> 行、第 <em>N</em> 列的像素都是海洋。</p><p>输出一个整数表示答案。</p><h3 id="思路-2"><a href="#思路-2" class="headerlink" title="思路"></a>思路</h3><p>这其实是一个求连通集的问题。</p><h3 id="代码-6"><a href="#代码-6" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">char</span> island[][] = <span class="keyword">new</span> <span class="keyword">char</span>[<span class="number">1001</span>][<span class="number">1001</span>];</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> total = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> dir[][] = <span class="keyword">new</span> <span class="keyword">int</span>[][]{{<span class="number">1</span>,<span class="number">0</span>},{-<span class="number">1</span>,<span class="number">0</span>},{<span class="number">0</span>,<span class="number">1</span>},{<span class="number">0</span>,-<span class="number">1</span>}};</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> N;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">boolean</span> flag = <span class="keyword">false</span>;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> N = scan.nextInt();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < N;i++){</span><br><span class="line"> String mid = scan.next();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;j < N;j++){</span><br><span class="line"> island[i][j] = mid.charAt(j);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">// for(int i = 0;i < N;i++){</span></span><br><span class="line"> <span class="comment">// for(int j = 0;j < N;j++){</span></span><br><span class="line"> <span class="comment">// System.out.print(island[i][j]);</span></span><br><span class="line"> <span class="comment">// }</span></span><br><span class="line"> <span class="comment">// System.out.println("");</span></span><br><span class="line"> <span class="comment">// }</span></span><br><span class="line"> <span class="comment">//实质上是求连通集</span></span><br><span class="line"> <span class="keyword">int</span> sum = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < N;i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;j < N;j++){</span><br><span class="line"> <span class="keyword">if</span>(island[i][j] == <span class="string">'#'</span>){</span><br><span class="line"> flag = <span class="keyword">false</span>;<span class="comment">//用于表示当前岛屿是否会被全部淹掉</span></span><br><span class="line"> sum++;</span><br><span class="line"> dfs(i,j);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> System.out.println(sum - total);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">//深度优先搜索</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>{</span><br><span class="line"> <span class="keyword">int</span> count = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">if</span>(!flag){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">4</span>;i++){</span><br><span class="line"> <span class="keyword">int</span> nx = x + dir[i][<span class="number">0</span>];</span><br><span class="line"> <span class="keyword">int</span> ny = y + dir[i][<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">if</span>(nx < N && ny < N && nx >= <span class="number">0</span> && ny >= <span class="number">0</span> && island[nx][ny] != <span class="string">'.'</span>){</span><br><span class="line"> count++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//说明四个方向都不是海,可以保留</span></span><br><span class="line"> <span class="keyword">if</span>(count == <span class="number">4</span>){</span><br><span class="line"> total++;<span class="comment">//剩余的岛屿</span></span><br><span class="line"> flag = <span class="keyword">true</span>;</span><br><span class="line"> }</span><br><span class="line"> island[x][y] = <span class="string">'*'</span>;<span class="comment">//设置为已经遍历过</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < <span class="number">4</span>;i++){</span><br><span class="line"> <span class="keyword">int</span> nx = x + dir[i][<span class="number">0</span>];</span><br><span class="line"> <span class="keyword">int</span> ny = y + dir[i][<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">if</span>(nx < N && ny < N && nx >= <span class="number">0</span> && ny >= <span class="number">0</span> && island[nx][ny] == <span class="string">'#'</span>){</span><br><span class="line"> dfs(nx,ny);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1 id="二分法"><a href="#二分法" class="headerlink" title="二分法"></a>二分法</h1><h2 id="分巧克力-2017省赛"><a href="#分巧克力-2017省赛" class="headerlink" title="分巧克力(2017省赛)"></a>分巧克力(2017省赛)</h2><h3 id="题目描述-7"><a href="#题目描述-7" class="headerlink" title="题目描述"></a>题目描述</h3><p>儿童节那天有 K 位小朋友到小明家做客。小明拿出了珍藏的巧克力招待小朋友们。</p><p>小明一共有 N 块巧克力,其中第 <em>i</em> 块是 Hi×Wi 的方格组成的长方形。为了公平起见,</p><p>小明需要从这 N 块巧克力中切出 K 块巧克力分给小朋友们。切出的巧克力需要满足:</p><ol><li>形状是正方形,边长是整数;</li><li>大小相同;</li></ol><p>例如一块 6x5 的巧克力可以切出 6 块 2x2 的巧克力或者 2 块 3x3 的巧克力。</p><p>当然小朋友们都希望得到的巧克力尽可能大,你能帮小明计算出最大的边长是多少么?</p><h3 id="输入描述-4"><a href="#输入描述-4" class="headerlink" title="输入描述"></a>输入描述</h3><p>第一行包含两个整数N,K (1≤N,K≤105)。</p><p>以下 N 行每行包含两个整数 Hi,Wi (1≤Hi,Wi≤105)。</p><p>输入保证每位小朋友至少能获得一块 1x1 的巧克力。</p><h3 id="输出描述-3"><a href="#输出描述-3" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出切出的正方形巧克力最大可能的边长。</p><h3 id="思路-3"><a href="#思路-3" class="headerlink" title="思路"></a>思路</h3><p>因为是找边长,我们很容易想到暴力求解,即:遍历1-10000,但是对于这种<strong>顺序找数字</strong>的问题,我们可以使用二分法,从0-10000中进行二分,找到合适的边长。<strong>二分法注意边界的取法</strong></p><h3 id="代码-7"><a href="#代码-7" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="keyword">int</span> N = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> K = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> H[] = <span class="keyword">new</span> <span class="keyword">int</span>[N+<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">int</span> W[] = <span class="keyword">new</span> <span class="keyword">int</span>[N+<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < N;i++){</span><br><span class="line"> H[i] = scan.nextInt();</span><br><span class="line"> W[i] = scan.nextInt();</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//二分法</span></span><br><span class="line"> <span class="keyword">int</span> minBorderLen = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">int</span> maxBorderLen = <span class="number">100000</span>;</span><br><span class="line"> <span class="keyword">int</span> finalBorderLen = <span class="number">1</span>;</span><br><span class="line"> <span class="keyword">while</span>(minBorderLen <= maxBorderLen){</span><br><span class="line"> <span class="keyword">int</span> midBorderLen = (minBorderLen + maxBorderLen) / <span class="number">2</span>;</span><br><span class="line"> <span class="keyword">int</span> sum = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < N;i++){</span><br><span class="line"> <span class="keyword">int</span> num = (H[i] / midBorderLen) * (W[i] / midBorderLen);</span><br><span class="line"> sum += num;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">if</span>(sum >= K){</span><br><span class="line"> minBorderLen = midBorderLen + <span class="number">1</span>;</span><br><span class="line"> finalBorderLen = midBorderLen;</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> maxBorderLen = midBorderLen - <span class="number">1</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> System.out.println(finalBorderLen);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1 id="动态规划"><a href="#动态规划" class="headerlink" title="动态规划"></a>动态规划</h1><h2 id="包子凑数"><a href="#包子凑数" class="headerlink" title="包子凑数"></a>包子凑数</h2><h3 id="题目描述-8"><a href="#题目描述-8" class="headerlink" title="题目描述"></a>题目描述</h3><p>小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有 N 种蒸笼,其中第 i 种蒸笼恰好能放 Ai 个包子。每种蒸笼都有非常多笼,可以认为是无限笼。</p><p>每当有顾客想买 X 个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有 X 个包子。比如一共有 3 种蒸笼,分别能放 3、4 和 5 个包子。当顾客想买 11 个包子时,大叔就会选 2 笼 3 个的再加 1 笼 5 个的(也可能选出 1 笼 3 个的再加 2 笼 4 个的)。</p><p>当然有时包子大叔无论如何也凑不出顾客想买的数量。比如一共有 3 种蒸笼,分别能放 4、5 和 6 个包子。而顾客想买 7 个包子时,大叔就凑不出来了。</p><p>小明想知道一共有多少种数目是包子大叔凑不出来的。</p><h3 id="输入描述-5"><a href="#输入描述-5" class="headerlink" title="输入描述"></a>输入描述</h3><p>第一行包含一个整数 N(1≤N≤100)。</p><p>以下 N 行每行包含一个整数Ai (1≤Ai≤100)。</p><h3 id="输出描述-4"><a href="#输出描述-4" class="headerlink" title="输出描述"></a>输出描述</h3><p>一个整数代表答案。如果凑不出的数目有无限多个,输出 INF。</p><h3 id="思路-4"><a href="#思路-4" class="headerlink" title="思路"></a>思路</h3><p>第一眼感觉是<strong>完全背包问题</strong>,事实确实是的。只不过先要判断输入数据的<strong>最大公约数是否为1</strong>。</p><p>至于为什么判断的条件要是1,这是因为只有所有数据的最大公约数是1,则凑出的数目就没有约数的限制了。</p><p>如:假如数据是4,6,则凑出的数目就有个限制,它的公约数得含有2,则奇数它是无法凑出的,而奇数有无限多个。</p><h3 id="代码-8"><a href="#代码-8" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="keyword">int</span> N = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> volume[] = <span class="keyword">new</span> <span class="keyword">int</span>[N+<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">int</span> dp[] = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">10001</span>];</span><br><span class="line"> <span class="keyword">int</span> common;</span><br><span class="line"> volume[<span class="number">0</span>] = scan.nextInt();</span><br><span class="line"> common = volume[<span class="number">0</span>];</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i < N;i++){</span><br><span class="line"> volume[i] = scan.nextInt();</span><br><span class="line"> common = gcd(common,volume[i]);</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">if</span>(common != <span class="number">1</span>){</span><br><span class="line"> System.out.println(<span class="string">"INF"</span>);</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> <span class="comment">//初始化</span></span><br><span class="line"> </span><br><span class="line"> dp[<span class="number">0</span>] = <span class="number">1</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i < N;i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;volume[i] + j <= <span class="number">10000</span>;j++){</span><br><span class="line"> <span class="keyword">if</span>(dp[j] == <span class="number">1</span>){ <span class="comment">//说明这个也可以根据组合得到</span></span><br><span class="line"> dp[volume[i] + j] = <span class="number">1</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i <= <span class="number">10000</span>;i++){</span><br><span class="line"> <span class="keyword">if</span>(dp[i] == <span class="number">0</span>){</span><br><span class="line"> counts++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> System.out.println(counts);</span><br><span class="line"> }</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">gcd</span><span class="params">(<span class="keyword">int</span> a,<span class="keyword">int</span> b)</span></span>{</span><br><span class="line"></span><br><span class="line"> <span class="keyword">while</span>(a % b != <span class="number">0</span>){</span><br><span class="line"> <span class="keyword">int</span> mid = a % b;</span><br><span class="line"> <span class="keyword">if</span>(mid == <span class="number">0</span>){</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"> a = b;</span><br><span class="line"> b = mid;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> b;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1 id="思维"><a href="#思维" class="headerlink" title="思维"></a>思维</h1><h2 id="删除字符"><a href="#删除字符" class="headerlink" title="删除字符"></a>删除字符</h2><h3 id="题目描述-9"><a href="#题目描述-9" class="headerlink" title="题目描述"></a>题目描述</h3><p>给定一个单词,请问在单词中删除 t 个字母后,能得到的字典序最小的单词是什么?</p><h3 id="输入描述-6"><a href="#输入描述-6" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入的第一行包含一个单词,由大写英文字母组成。</p><p>第二行包含一个正整数 <em>t</em>。</p><p>其中,单词长度不超过 100100,<em>t</em> 小于单词长度。</p><h3 id="输出描述-5"><a href="#输出描述-5" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出一个单词,表示答案。</p><h3 id="思路-5"><a href="#思路-5" class="headerlink" title="思路"></a>思路</h3><p>这个得搞清楚什么是字典序,这个其实是用来比较字符串大小时可能用到的,如abcde的字典序大于aabcd的字典序,怎么比的呢?</p><p>先比较a,a是相同的,然后比较第二个字符,b>a说明第一个字典序比第二个大。</p><p>理解了字典序后,这题就比较简单了,我们得先判断当前字母是不是字典序最小的,这个可以将它与它后面的字母进行比较,如果不是最小的,则将它删除掉,最后删除t个字母就结束。</p><p>最后得到的结果就是答案了。</p><h3 id="代码-9"><a href="#代码-9" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> String ss = scan.nextLine();</span><br><span class="line"> <span class="keyword">int</span> t = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> len = ss.length();</span><br><span class="line"> <span class="keyword">char</span> chs[] = ss.toCharArray();</span><br><span class="line"> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">boolean</span> isDelete[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[len+<span class="number">1</span>];</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < len; i++){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = i + <span class="number">1</span>;j < len;j++){</span><br><span class="line"> <span class="keyword">if</span>(chs[i] > chs[j]){</span><br><span class="line"> isDelete[i] = <span class="keyword">true</span>;</span><br><span class="line"> counts ++;</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(counts == t){</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < len;i++){</span><br><span class="line"> <span class="keyword">if</span>(!isDelete[i]){</span><br><span class="line"> System.out.print(chs[i]);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="货物摆放-2021省赛"><a href="#货物摆放-2021省赛" class="headerlink" title="货物摆放(2021省赛)"></a>货物摆放(2021省赛)</h2><h3 id="题目描述-10"><a href="#题目描述-10" class="headerlink" title="题目描述"></a>题目描述</h3><p>小蓝有一个超大的仓库,可以摆放很多货物。</p><p>现在,小蓝有 n 箱货物要摆放在仓库,每箱货物都是规则的正方体。小蓝规定了长、宽、高三个互相垂直的方向,每箱货物的边都必须严格平行于长、宽、高。</p><p>小蓝希望所有的货物最终摆成一个大的长方体。即在长、宽、高的方向上分别堆 <em>L</em>、<em>W</em>、<em>H</em> 的货物,满足 n=L×W×H。</p><p>给定 <em>n</em>,请问有多少种堆放货物的方案满足要求。</p><p>例如,当n=4 时,有以下 66 种方案:1×1×4、1×2×2、1×4×1、2×1×2、2 × 2 × 1、4 × 1 × 11×1×4、1×2×2、1×4×1、2×1×2、2×2×1、4×1×1。</p><p>请问,当 n=2021041820210418 (注意有 1616 位数字)时,总共有多少种方案?</p><p>提示:建议使用计算机编程解决问题。</p><h3 id="思路-6"><a href="#思路-6" class="headerlink" title="思路"></a>思路</h3><p>第一次做的时候是懵的,被这么大的数吓住了,其实这个用Long就行了,然后算出该数的因数,最后三层循环遍历即可。</p><h3 id="代码-10"><a href="#代码-10" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> Long num = <span class="keyword">new</span> Long(<span class="string">"2021041820210418"</span>);</span><br><span class="line"> <span class="keyword">int</span> counts = <span class="number">0</span>;</span><br><span class="line"> List<Long> yinzi = <span class="keyword">new</span> ArrayList<>();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">long</span> i = <span class="number">1</span>; i * i <= num;i++){</span><br><span class="line"> <span class="keyword">if</span>(num % i == <span class="number">0</span>){</span><br><span class="line"> yinzi.add(i);</span><br><span class="line"> <span class="keyword">if</span>(num / i != i){</span><br><span class="line"> yinzi.add(num/i);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">int</span> res = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">long</span> i:yinzi){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">long</span> j:yinzi){</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">long</span> t:yinzi){</span><br><span class="line"> <span class="keyword">if</span>(i * j * t == num){</span><br><span class="line"> res++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> System.out.println(res);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="字串分值-2020省赛"><a href="#字串分值-2020省赛" class="headerlink" title="字串分值(2020省赛)"></a>字串分值(2020省赛)</h2><h3 id="题目描述-11"><a href="#题目描述-11" class="headerlink" title="题目描述"></a>题目描述</h3><p>对于一个字符串 S,我们定义 S 的分值 f(S) 为 S 中恰好出现一次的字符个数。例如 f(aba)=1,f(abc)=3,f(aaa)=0。</p><p>现在给定一个字符串 S0⋯n−1(长度为 n,1≤n≤105),请你计算对于所有S 的非空子串 Si⋯j(0≤i≤j<n),f(Si⋯j) 的和是多少。</p><h3 id="输入描述-7"><a href="#输入描述-7" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入一行包含一个由小写字母组成的字符串 S。</p><h3 id="输出描述-6"><a href="#输出描述-6" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出一个整数表示答案。</p><h3 id="思路-7"><a href="#思路-7" class="headerlink" title="思路"></a>思路</h3><p>这道题可以用暴力解法,但是本题的本意并不是在这里。这里其实是求字母的贡献度,只有当字母个数在子串中个数为1才会有贡献度。</p><p>对此,我们可以从要分析字母A的左右两边出发,分别计算移动了多远才会出现一个字母与A相同,然后停止遍历,记录下步长left和right。然后是怎么算总的贡献度。</p><p>当前**字母的贡献度=(left+1) * (right+1)**。为什么是这个呢?</p><p>以<strong>bacbacdb</strong>为例,我们对第四个字母b进行分析:</p><ul><li>先往左边遍历,可以移动两个单位,则left = 2;</li><li>再往右边遍历,可以移动3个单位,则right = 3;</li></ul><p>则对于b字母,有贡献度的部分为acbacd,满足的字串(<strong>注意要有b</strong>)有:</p><ul><li>从左边第一个字母a开始,分别是acb,acba,acbac,acbacd,有4个</li><li>然后左边从第二个字母c开始,为cb,cba,cbac,cbacd,有4个</li><li>从左边第三个字母b开始,为b,ba,bac,bacd,有4个</li></ul><p>我们在分析过程中可以得到规律,就是**(往左移动的步数+1) * (往右移动的步数+1)<strong>,加1是因为</strong>要包含分析的字母**。</p><h3 id="代码-11"><a href="#代码-11" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> String str = scan.next();</span><br><span class="line"> <span class="keyword">char</span> chs[] = str.toCharArray();</span><br><span class="line"> <span class="keyword">int</span> len = str.length();</span><br><span class="line"> <span class="keyword">int</span> res = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < len;i++){</span><br><span class="line"> <span class="keyword">int</span> left = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">int</span> right = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">char</span> c = chs[i];</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = i - <span class="number">1</span>;j >=<span class="number">0</span> && chs[j] != c;j --){</span><br><span class="line"> left++;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j = i + <span class="number">1</span>;j < len && chs[j] != c;j++){</span><br><span class="line"> right++;</span><br><span class="line"> }</span><br><span class="line"> res += (left+<span class="number">1</span>)*(right+<span class="number">1</span>);</span><br><span class="line"> }</span><br><span class="line"> System.out.println(res);</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="螺旋折线-2018省赛"><a href="#螺旋折线-2018省赛" class="headerlink" title="螺旋折线(2018省赛)"></a>螺旋折线(2018省赛)</h2><h3 id="题目描述-12"><a href="#题目描述-12" class="headerlink" title="题目描述"></a>题目描述</h3><p>如下图所示的螺旋折线经过平面上所有整点恰好一次。</p><p><img src="https://doc.shiyanlou.com/courses/uid1580206-20210202-1612250322579" alt="img"></p><p>对于整点 (X,Y),我们定义它到原点的距离 dis(X,Y) 是从原点到 (X,Y) 的螺旋折线段的长度。</p><p>例如 dis(0,1)=3,dis(−2,−1)=9。</p><p>给出整点坐标 (X,Y),你能计算出 dis(X,Y) 吗?</p><h3 id="输入描述-8"><a href="#输入描述-8" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入格式:</p><p>输入一行,X和Y,−109≤X,Y≤109。</p><h3 id="输出描述-7"><a href="#输出描述-7" class="headerlink" title="输出描述"></a>输出描述</h3><p>输出 dis(X,Y)。</p><h3 id="思路-8"><a href="#思路-8" class="headerlink" title="思路"></a>思路</h3><p>刚开始时使用的时递归,但是由于数据量太大,爆栈了,所以递归行不通。</p><p>其实我们可以找规律。很明显的,这个图是有一定规律的,可以将其看成很多个正方形,只要把中间断的补齐就好了。</p><p>如图:</p><p>有了上面的思路,就先找到点所处的正方形。通过观察我们可以发现规律,点所处的正方形的边长为2 * max(abs(X),abs(Y))。</p><p>找到边长后,我们进行下面两步:</p><ul><li>计算之前的正方形边长之和,这是一个等差数列求和</li><li>计算从点所处正方形的开始位置到点的位置所需要经过的步数</li></ul><p>算完之后,两者相加即可。</p><h3 id="代码-12"><a href="#代码-12" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">long</span> X,Y;</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">long</span> res = <span class="number">0</span>;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String args[])</span> </span>{</span><br><span class="line"> Scanner scanner = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> X = scanner.nextLong();</span><br><span class="line"> Y = scanner.nextLong();</span><br><span class="line"> <span class="keyword">long</span> maxLen = Math.max(Math.abs(X), Math.abs(Y));</span><br><span class="line"> <span class="keyword">long</span> preSum = ((maxLen - <span class="number">1</span>) * maxLen) * <span class="number">4</span>;</span><br><span class="line"> <span class="keyword">long</span> remain = calRemain(X, Y, maxLen);</span><br><span class="line"> System.out.println(preSum+remain);</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">long</span> <span class="title">calRemain</span><span class="params">(<span class="keyword">long</span> x,<span class="keyword">long</span> y,<span class="keyword">long</span> border)</span> </span>{</span><br><span class="line"> <span class="comment">//边长</span></span><br><span class="line"> <span class="keyword">long</span> width = <span class="number">2</span> * border;</span><br><span class="line"> <span class="keyword">long</span> result = <span class="number">0l</span>;</span><br><span class="line"> <span class="keyword">if</span>(x == -border && y != border) {</span><br><span class="line"> result = y - (-border);</span><br><span class="line"> <span class="keyword">return</span> result;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(y == border) {</span><br><span class="line"> result = width + x - (-border);</span><br><span class="line"> <span class="keyword">return</span> result;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(x == border) {</span><br><span class="line"> result = <span class="number">2</span> * width + border - y;</span><br><span class="line"> <span class="keyword">return</span> result;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(y == -border) {</span><br><span class="line"> result = <span class="number">8</span> * border - (x - (-border));</span><br><span class="line"> <span class="keyword">return</span> result;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0l</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="平面切分"><a href="#平面切分" class="headerlink" title="平面切分"></a>平面切分</h2><h3 id="题目描述-13"><a href="#题目描述-13" class="headerlink" title="题目描述"></a>题目描述</h3><p>平面上有 N 条直线,其中第 i 条直线是 y=A i×x+B i。</p><p>请计算这些直线将平面分成了几个部分。</p><h3 id="输入描述-9"><a href="#输入描述-9" class="headerlink" title="输入描述"></a>输入描述</h3><p>第一行包含一个整数 N。</p><p>以下 N 行,每行包含两个整数 Ai,Bi。</p><p>其中,1≤N≤1000,−105≤Ai,Bi≤105。</p><h3 id="输出描述-8"><a href="#输出描述-8" class="headerlink" title="输出描述"></a>输出描述</h3><p>一个整数代表答案。</p><h3 id="思路-9"><a href="#思路-9" class="headerlink" title="思路"></a>思路</h3><p>这其实是一个找规律的问题,我们通过在纸上画几张示例,可以发现:</p><p>若平面上已经有n条直线,当我们再加一条时</p><ul><li>若该直线与n条直线有m个交点,则会新增(m+1)个平面</li></ul><p>同时,我们需要注意直线是否重合,重合的话就没必要讨论,跳过该条直线,除此之外,还有直线与直线交点也可能重复,所以我们需要去重,这里我们使用set进行去重。</p><h3 id="代码-13"><a href="#代码-13" class="headerlink" title="代码"></a>代码</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string"><bits/stdc++.h></span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="keyword">long</span> <span class="keyword">double</span> s[<span class="number">1010</span>][<span class="number">2</span>];<span class="comment">//存储直线的A,B </span></span><br><span class="line"><span class="keyword">long</span> <span class="keyword">long</span> ans;</span><br><span class="line"><span class="keyword">bool</span> st[<span class="number">1010</span>]; <span class="comment">//false表示不是重边 </span></span><br><span class="line">pair<<span class="keyword">long</span> <span class="keyword">double</span>,<span class="keyword">long</span> <span class="keyword">double</span>> p;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>{</span><br><span class="line"> <span class="keyword">int</span> n;</span><br><span class="line"> cin>>n;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i<n;i++){</span><br><span class="line"> cin>>s[i][<span class="number">0</span>]>>s[i][<span class="number">1</span>];</span><br><span class="line"> set<pair<<span class="keyword">long</span> <span class="keyword">double</span>,<span class="keyword">long</span> <span class="keyword">double</span>> > points;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j<i;j++){</span><br><span class="line"> <span class="keyword">if</span>(st[j])<span class="keyword">continue</span>;<span class="comment">//直线是重边,跳过 </span></span><br><span class="line"> <span class="keyword">if</span>(s[i][<span class="number">0</span>]==s[j][<span class="number">0</span>]){<span class="comment">//两条直线斜率相等时,判断是平行还是重合 </span></span><br><span class="line"> <span class="keyword">if</span>(s[i][<span class="number">1</span>]==s[j][<span class="number">1</span>]){</span><br><span class="line"> st[i]=<span class="literal">true</span>;<span class="comment">//待添加直线是重边,退出循环 </span></span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }<span class="keyword">else</span> <span class="keyword">continue</span>;<span class="comment">//直线平行,不需要计算交点 </span></span><br><span class="line"> }</span><br><span class="line"> p.first=(s[j][<span class="number">1</span>]-s[i][<span class="number">1</span>])/(s[i][<span class="number">0</span>]-s[j][<span class="number">0</span>]);<span class="comment">//交点的x坐标 </span></span><br><span class="line"> p.second=s[i][<span class="number">0</span>]*p.first+s[i][<span class="number">1</span>];<span class="comment">//交点的y坐标 </span></span><br><span class="line"> points.<span class="built_in">insert</span>(p);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(!st[i])ans+=points.<span class="built_in">size</span>()+<span class="number">1</span>;<span class="comment">//若当前直线不是重边,更新答案 </span></span><br><span class="line"> }</span><br><span class="line"> cout<<ans+<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1 id="双指针"><a href="#双指针" class="headerlink" title="双指针"></a>双指针</h1><h2 id="日志统计"><a href="#日志统计" class="headerlink" title="日志统计"></a>日志统计</h2><h3 id="题目描述-14"><a href="#题目描述-14" class="headerlink" title="题目描述"></a>题目描述</h3><p>小明维护着一个程序员论坛。现在他收集了一份”点赞”日志,日志共有 <em>N</em> 行。其中每一行的格式是:</p><p>ts,id</p><p>表示在 <em>t</em> <em>s</em> 时刻编号 <em>i</em> <em>d</em> 的帖子收到一个”赞”。</p><p>现在小明想统计有哪些帖子曾经是”热帖”。如果一个帖子曾在任意一个长度为 <em>D</em> 的时间段内收到不少于 <em>K</em> 个赞,小明就认为这个帖子曾是”热帖”。</p><p>具体来说,如果存在某个时刻 T 满足该帖在 [<em>T</em>,<em>T</em>+<em>D</em>) 这段时间内(注意是左闭右开区间)收到不少于 <em>K</em> 个赞,该帖就曾是”热帖”。</p><p>给定日志,请你帮助小明统计出所有曾是”热帖”的帖子编号。</p><h3 id="输入描述-10"><a href="#输入描述-10" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入格式:</p><p>第一行包含三个整数 <em>N</em>,<em>D</em>,<em>K</em>。</p><p>以下 N 行每行一条日志,包含两个整数 ts 和 id。</p><p>其中, 1≤<em>K</em>≤<em>N</em>≤105,0≤<em>t**s</em>≤105,0≤<em>i**d</em>≤105。</p><h3 id="输出描述-9"><a href="#输出描述-9" class="headerlink" title="输出描述"></a>输出描述</h3><p>按从小到大的顺序输出热帖 <em>i</em> <em>d</em>。每个 <em>i</em> <em>d</em> 一行。</p><h3 id="思路-10"><a href="#思路-10" class="headerlink" title="思路"></a>思路</h3><p>先将数据按id从小到大排序,同一id的话按时间从小到大排序,然后我们通过双指针i,j来解决该问题。</p><p>其中i是当前id前一时刻所处的位置,j为当前id之后时间所处的位置</p><p>i更新的条件分为两种情况</p><ul><li>我们已经遍历到另外一个id的评论了,即record[i].id!=record[j].id,此时更新i为j</li><li>还是处于同一个评论id,但是和j所处的评论时间相差超过了D,此时i的指针向前移动,即i++</li></ul><p>j更新的条件是处于同一id下且相差的时间不超过D</p><h3 id="代码-14"><a href="#代码-14" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="keyword">import</span> java.util.*;</span><br><span class="line"><span class="comment">// 1:无需package</span></span><br><span class="line"><span class="comment">// 2: 类名必须Main, 不可修改</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>{</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Record</span></span>{</span><br><span class="line"> <span class="keyword">int</span> time;</span><br><span class="line"> <span class="keyword">int</span> id;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="title">Record</span><span class="params">(<span class="keyword">int</span> time,<span class="keyword">int</span> id)</span></span>{</span><br><span class="line"> <span class="keyword">this</span>.id = id;</span><br><span class="line"> <span class="keyword">this</span>.time = time;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String args[])</span></span>{</span><br><span class="line"> Scanner scan = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line"> <span class="comment">//在此输入您的代码...</span></span><br><span class="line"> <span class="keyword">int</span> N = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> D = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> K = scan.nextInt();</span><br><span class="line"> <span class="keyword">int</span> ts = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">int</span> id = <span class="number">0</span>;</span><br><span class="line"> <span class="comment">//判断该帖子是否满足热门帖子</span></span><br><span class="line"> <span class="keyword">boolean</span> hasMeet[] = <span class="keyword">new</span> <span class="keyword">boolean</span>[<span class="number">100001</span>];</span><br><span class="line"> Record record[] = <span class="keyword">new</span> Record[N];</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < N;i++){</span><br><span class="line"> ts = scan.nextInt();</span><br><span class="line"> id = scan.nextInt();</span><br><span class="line"> record[i] = <span class="keyword">new</span> Record(ts,id);</span><br><span class="line"> }</span><br><span class="line"> Arrays.sort(record, <span class="number">0</span>, N, <span class="keyword">new</span> Comparator<Record>() {</span><br><span class="line"> <span class="meta">@Override</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">compare</span><span class="params">(Record o1, Record o2)</span> </span>{</span><br><span class="line"> <span class="keyword">if</span>(o1.id == o2.id){</span><br><span class="line"> <span class="keyword">return</span> o1.time - o2.time;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> o1.id - o2.id;</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"></span><br><span class="line"><span class="comment">// System.out.println("排序后结果:");</span></span><br><span class="line"><span class="comment">// for(int i = 0;i < N;i++){</span></span><br><span class="line"><span class="comment">// System.out.println(record[i].time + " " + record[i].id);</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"> <span class="keyword">int</span> id_max = record[N-<span class="number">1</span>].id;</span><br><span class="line"> <span class="comment">//使用双指针</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>,j = <span class="number">0</span>;i < N;){</span><br><span class="line"> <span class="keyword">while</span>(j < N && record[i].id == record[j].id && record[j].time - record[i].time < D){</span><br><span class="line"> <span class="comment">//指针向前移动</span></span><br><span class="line"> j++;</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">//点赞数满足</span></span><br><span class="line"> <span class="keyword">if</span>(j - i >= K){</span><br><span class="line"> hasMeet[record[i].id] = <span class="keyword">true</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">if</span>(i >= N || j >= N){</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">if</span>(record[i].id != record[j].id){</span><br><span class="line"> <span class="comment">//此时是另外一个编号的评论了</span></span><br><span class="line"> i = j;</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> <span class="comment">//说明只是时间间隔超过了D,则把时间往后移</span></span><br><span class="line"> i++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i <= id_max;i++){</span><br><span class="line"> <span class="keyword">if</span>(hasMeet[i]){</span><br><span class="line"> System.out.println(i);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> scan.close();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1 id="记忆化搜索"><a href="#记忆化搜索" class="headerlink" title="记忆化搜索"></a>记忆化搜索</h1><h2 id="地宫取宝"><a href="#地宫取宝" class="headerlink" title="地宫取宝"></a>地宫取宝</h2><h3 id="题目描述-15"><a href="#题目描述-15" class="headerlink" title="题目描述"></a>题目描述</h3><p>X 国王有一个地宫宝库。是 n×m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。</p><p>地宫的入口在左上角,出口在右下角。</p><p>小明被带到地宫的入口,国王要求他只能向右或向下行走。</p><p>走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。</p><p>当小明走到出口时,如果他手中的宝贝恰好是 k件,则这些宝贝就可以送给小明。</p><p>请你帮小明算一算,在给定的局面下,他有多少种不同的行动方案能获得这 k 件宝贝。</p><h3 id="输入描述-11"><a href="#输入描述-11" class="headerlink" title="输入描述"></a>输入描述</h3><p>输入一行 3 个整数,用空格分开:n,m,k(1≤n,m≤50,1≤k≤12)。</p><p>接下来有 n 行数据,每行有 m个整数Ci (0≤Ci≤12) 代表这个格子上的宝物的价值。</p><h3 id="输出描述-10"><a href="#输出描述-10" class="headerlink" title="输出描述"></a>输出描述</h3><p>要求输出一个整数,表示正好取 k个宝贝的行动方案数。该数字可能很大,输出它对 109+7 取模的结果。</p><h3 id="代码-15"><a href="#代码-15" class="headerlink" title="代码"></a>代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Arrays;</span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"><span class="keyword">import</span> java.util.zip.ZipEntry;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UndergroundTakeTreasure</span> </span>{</span><br><span class="line"><span class="keyword">static</span> <span class="keyword">int</span> treasure[][];</span><br><span class="line"><span class="keyword">static</span> <span class="keyword">int</span> n,m,k;</span><br><span class="line"><span class="keyword">static</span> <span class="keyword">int</span> dp[][][][];</span><br><span class="line"><span class="keyword">static</span> <span class="keyword">int</span> MOD = <span class="number">1000000007</span>;</span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String args[])</span> </span>{</span><br><span class="line">Scanner scanner = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line">n = scanner.nextInt();</span><br><span class="line">m = scanner.nextInt();</span><br><span class="line">k = scanner.nextInt();</span><br><span class="line">treasure = <span class="keyword">new</span> <span class="keyword">int</span>[n][m];</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < n;i++) {</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;j < m;j++) {</span><br><span class="line">treasure[i][j] = scanner.nextInt();</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">init();</span><br><span class="line"><span class="keyword">int</span> result = dfs(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, -<span class="number">1</span>);</span><br><span class="line">System.out.println(result);</span><br><span class="line">scanner.close();</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 记忆化搜索</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> x</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> y</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> num 手上的宝物数目</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> max 手上宝物的值的最大值</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y,<span class="keyword">int</span> num,<span class="keyword">int</span> max)</span> </span>{</span><br><span class="line"><span class="comment">//不满足的情况</span></span><br><span class="line"><span class="keyword">if</span>(x < <span class="number">0</span> || x >= n || y < <span class="number">0</span> || y >= m || num > k) {</span><br><span class="line"><span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span>(dp[x][y][max+<span class="number">1</span>][num] != -<span class="number">1</span>) {</span><br><span class="line"><span class="comment">//说明这种情况之前出现过</span></span><br><span class="line"><span class="keyword">return</span> dp[x][y][max+<span class="number">1</span>][num];</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//到达终点了</span></span><br><span class="line"><span class="keyword">int</span> value = treasure[x][y];</span><br><span class="line"><span class="keyword">if</span>(x == n - <span class="number">1</span> && y == m - <span class="number">1</span>) {</span><br><span class="line"><span class="keyword">if</span>(num == k || (num == k - <span class="number">1</span> && value > max)) {</span><br><span class="line"><span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line">}</span><br><span class="line"><span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//进行向右或者向下移动</span></span><br><span class="line"><span class="keyword">int</span> result = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">if</span>(value > max) {</span><br><span class="line"><span class="comment">//这是拿宝物的情况</span></span><br><span class="line"><span class="comment">//向右移动</span></span><br><span class="line">result += dfs(x+<span class="number">1</span>, y, num+<span class="number">1</span>, value);</span><br><span class="line">result %= MOD;</span><br><span class="line"><span class="comment">//向下移动</span></span><br><span class="line">result += dfs(x, y+<span class="number">1</span>, num+<span class="number">1</span>, value);</span><br><span class="line">result %= MOD;</span><br><span class="line">}</span><br><span class="line"><span class="comment">//不拿宝物</span></span><br><span class="line"><span class="comment">//向右移动</span></span><br><span class="line">result += dfs(x+<span class="number">1</span>, y, num, max);</span><br><span class="line">result %= MOD;</span><br><span class="line"><span class="comment">//向下移动</span></span><br><span class="line">result += dfs(x, y+<span class="number">1</span>, num, max);</span><br><span class="line">result %= MOD;</span><br><span class="line">dp[x][y][max+<span class="number">1</span>][num] = result;</span><br><span class="line"><span class="comment">//注意这是max+1,因为max是-1开始的</span></span><br><span class="line"><span class="keyword">return</span> result;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 对dp进行初始化</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">init</span><span class="params">()</span> </span>{</span><br><span class="line">dp = <span class="keyword">new</span> <span class="keyword">int</span>[n+<span class="number">1</span>][m+<span class="number">1</span>][<span class="number">15</span>][<span class="number">15</span>];</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i < n;i ++) {</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>;j < m;j ++) {</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> t = <span class="number">0</span>;t < <span class="number">15</span>;t ++) {</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> z = <span class="number">0</span>;z < <span class="number">15</span>;z ++) {</span><br><span class="line">dp[i][j][t][z] = -<span class="number">1</span>;</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>[toc]</p>
<h1 id="DFS算法"><a href="#DFS算法" class="headerlink" title="DFS算法"></a>DFS算法</h1><h2 id="迷宫-2017年省赛"><a href="#迷宫-2017年省赛" class=</summary>
<category term="题解" scheme="https://lzl2040.github.io/categories/%E9%A2%98%E8%A7%A3/"/>
<category term="蓝桥杯" scheme="https://lzl2040.github.io/tags/%E8%93%9D%E6%A1%A5%E6%9D%AF/"/>
</entry>
<entry>
<title>Hexo部署博客项目</title>
<link href="https://lzl2040.github.io/2022/01/27/Hexo%E9%83%A8%E7%BD%B2%E5%8D%9A%E5%AE%A2%E9%A1%B9%E7%9B%AE/"/>
<id>https://lzl2040.github.io/2022/01/27/Hexo%E9%83%A8%E7%BD%B2%E5%8D%9A%E5%AE%A2%E9%A1%B9%E7%9B%AE/</id>
<published>2022-01-27T09:37:59.000Z</published>
<updated>2022-09-14T14:37:18.688Z</updated>
<content type="html"><![CDATA[<h1 id="hexo使用教程"><a href="#hexo使用教程" class="headerlink" title="hexo使用教程"></a>hexo使用教程</h1><h2 id="使用教程"><a href="#使用教程" class="headerlink" title="使用教程"></a>使用教程</h2><h3 id="1-创建博客项目"><a href="#1-创建博客项目" class="headerlink" title="1.创建博客项目"></a>1.创建博客项目</h3><p>使用命令</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo init 项目名称</span><br></pre></td></tr></table></figure><h3 id="2-创建一篇新的博客"><a href="#2-创建一篇新的博客" class="headerlink" title="2.创建一篇新的博客"></a>2.创建一篇新的博客</h3><p>使用命令</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new post '文章名'</span><br></pre></td></tr></table></figure><h3 id="3-生成静态文件"><a href="#3-生成静态文件" class="headerlink" title="3.生成静态文件"></a>3.生成静态文件</h3><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure><h3 id="4-部署远程仓库"><a href="#4-部署远程仓库" class="headerlink" title="4.部署远程仓库"></a>4.部署远程仓库</h3><p>找到config.yml文件,在其最下面找到deploy项目,加入如下:</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line"> type: git</span><br><span class="line"> repository: git@github.com:yourName/yourName.github.io.git # 码云仓库</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure><h3 id="5-部署到GitHub上"><a href="#5-部署到GitHub上" class="headerlink" title="5.部署到GitHub上"></a>5.部署到GitHub上</h3><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure><p>这样,一个hexo博客项目就被部署到GitHub上了。</p><h2 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h2><h3 id="1-extends-includes-layout-pug-block-content-include-includes-mixins-post-ui-pug-recent-posts-recent-posts-postUI-include-includes-pagination-pug"><a href="#1-extends-includes-layout-pug-block-content-include-includes-mixins-post-ui-pug-recent-posts-recent-posts-postUI-include-includes-pagination-pug" class="headerlink" title="1.extends includes/layout.pug block content include ./includes/mixins/post-ui.pug #recent-posts.recent-posts +postUI include includes/pagination.pug"></a>1.extends includes/layout.pug block content include ./includes/mixins/post-ui.pug #recent-posts.recent-posts +postUI include includes/pagination.pug</h3><h4 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h4><p>没有pug文件的渲染库</p><h4 id="解决办法"><a href="#解决办法" class="headerlink" title="解决办法"></a>解决办法</h4><p>使用命令</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive</span><br></pre></td></tr></table></figure><p>可能会有warning,但这个问题影响不大,warning通常是npm版本引起的,可以换一个不同的版本。</p><h3 id="2-Deployer-not-found-git"><a href="#2-Deployer-not-found-git" class="headerlink" title="2.Deployer not found: git"></a>2.Deployer not found: git</h3><h4 id="原因-1"><a href="#原因-1" class="headerlink" title="原因"></a>原因</h4><p>这是因为deployer程序还没安装</p><h4 id="解决办法-1"><a href="#解决办法-1" class="headerlink" title="解决办法"></a>解决办法</h4><p>使用命令</p><figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install --save hexo-deployer-git</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><h1 id="hexo使用教程"><a href="#hexo使用教程" class="headerlink" title="hexo使用教程"></a>hexo使用教程</h1><h2 id="使用教程"><a href="#使用教程" class="headerlink" </summary>
<category term="hexo" scheme="https://lzl2040.github.io/tags/hexo/"/>
</entry>
</feed>