codeforces 515d 拓扑排序/二分图

【DMA】认识 DMA 及其工作流程(与传统CPU存取方式的区别) 阅读详情
D. Drazil and Tiles
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Drazil created a following problem about putting 1 × 2 tiles into an n × m grid:

"There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should cover each other. And you should print a solution about how to do it."

But Drazil doesn't like to write special checking program for this task. His friend, Varda advised him: "how about asking contestant only to print the solution when it exists and it is unique? Otherwise contestant may print 'Not unique' ".

Drazil found that the constraints for this task may be much larger than for the original task!

Can you solve this new problem?

Note that you should print 'Not unique' either when there exists no solution or when there exists several different solutions for the original task.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2000).

The following n lines describe the grid rows. Character '.' denotes an empty cell, and the character '*' denotes a cell that is occupied.

Output

If there is no solution or the solution is not unique, you should print the string "Not unique".

Otherwise you should print how to cover all empty cells with 1 × 2 tiles. Use characters "<>" to denote horizontal tiles and characters "^v" to denote vertical tiles. Refer to the sample test for the output format example.

Sample test(s)
input
3 3
...
.*.
...
output
Not unique
input
4 4
..**
*...
*.**
....
output
<>**
*^<>
*v**
<><>
input
2 4
*..*
....
output
*<>*
<><>
input
1 1
.
output
Not unique
input
1 1
*
output
*
Note

In the first case, there are indeed two solutions:

<>^
^*v
v<>

and

^<>
v*^
<>v

so the answer is "Not unique".



题目给出一个n*m的网格,用1*2的砖块将上面的空地都铺满,输出方案是否唯一,若唯一输出解决方案。

把所有的格子当成点,相邻格子间连接一条边,并统计每个格子的度数。将所有度数为1的点放入队列中,度数为1的一定只有一种铺法。铺完更新周围的点的度数,将度数为1的入队,循环直到队列为空。如果此时还没铺满,则方案不唯一。

如果铺完度数为1的,那么剩下的点都是度数>=2,所有的边构成了一个二分图,并且一定存在一个环其中相邻的边可以染成不同颜色。所以如果有解则一定有>=2个解


#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>

using namespace std;

#define maxn 2005

int n,m;
char g[maxn][maxn];
int d[maxn][maxn];
int dir[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};

int main()
{
    while(scanf("%d%d", &n, &m)!=EOF){
        for(int i = 1; i <= n; i++)
            scanf("%s", g[i]+1);

        memset(d, 0, sizeof(d));
        int tot = 0;

        queue<int> q;
        for(int i = 1; i<= n;i++)
        for(int j =1; j<= m; j++){
            int nx,ny;
            if(g[i][j] != '.') continue;
            tot++;
            for(int k = 0; k < 4; k++){
                nx = i+dir[k][0], ny = j+dir[k][1];
                if(g[nx][ny] == '.')
                    d[i][j]++;
            }
            if(d[i][j] == 1)
                q.push(i*(m+1)+j);
        }

        int cnt = 0;
        while(!q.empty()){
            int x = q.front()/(m+1), y = q.front()%(m+1);
            q.pop();

            for(int i = 0; i < 4; i++){
                int nx = dir[i][0]+x, ny = dir[i][1]+y;
                if(g[nx][ny] != '.') continue;
                if(i == 0){
                    g[nx][ny] = '^';
                    g[x][y] = 'v';
                }
                else if(i == 1){
                    g[nx][ny] = 'v';
                    g[x][y] = '^';
                }
                else if(i == 2){
                    g[nx][ny] = '>';
                    g[x][y] = '<';
                }
                else{
                    g[nx][ny] = '<';
                    g[x][y] = '>';
                }

                cnt+=2;
                for(int k = 0; k < 4; k++){
                int nnx = nx+dir[k][0], nny = ny+dir[k][1];
                if(g[nnx][nny]!='.') continue;
                d[nnx][nny]--;
                if(d[nnx][nny] == 1)
                    q.push(nnx*(m+1)+nny);
                }

            }
        }

        if(cnt!=tot)
            printf("Not unique\n");
        else{
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++)
                    printf("%c", g[i][j]);
                printf("\n");
            }
        }

    }
    return 0;
}


【vue看板】 大屏看板提示:以下是本篇文章正文内容,下面案例可供参考提示:这里对文章进行总结:代码量较多,看板中的。 阅读详情

相关推荐

Rclone替代RaiDrive?零广告免费挂载Alist WebDAV到Windows资源管理器(含自启脚本)

本文详细介绍了如何使用开源工具Rclone替代RaiDrive,实现零广告、全免费的Alist WebDAV挂载方案。通过深入解析配置参数、提供完整的自启动解决方案和解决常见问题,帮助用户在Windows资源管理器中高效管理云存储,提升使用体验。

weixin_33709364的博客 633

CODEFORCES 515D Drazil and Tiles <路径dfs + 跳格>

题目:http://codeforces.com/problemset/problem/515/D 题意:给你一张方格,叫你用1X2填充方格,有些方格已经被占了(用‘*’),没被占的('.')。竖起来填,用 "^v"表示,横起来,用”Not unique". 分析:dfs一下,一对一对地找。 Input 3 3....*.... Output Not unique

论菜鸟的自我修养。。。 470

UFS 功能描述:UFS boot

UFS 启动过程介绍:启动配置,启动代码下载过程和安全性

m0_51720747的博客 1601

Drazil and Tiles CodeForces - 515D(思维+拓扑排序)这题强

题目链接 div2 的D题,比较好的一道拓扑排序了,一开始也没有发现咋用拓扑排序做。。 题意:铺砖,砖的大小为1 X 2. 然后要求你在给定的区域内为.的填充上砖,左右填充&lt;&gt;,上下填充^v; 题意分析: 1.这道题可以用拓扑排序做,可以遍历个点,找出其周围‘.’的个数。 2.如果周围'.'点的个数为1则必须对其进行安排。 3.不断拓扑遍历,直到结束,如果还有.则方法不为1...

fighting_yifeng的博客 319

HBF凭什么能挑战HBM?

最近AI圈聊得最多的,除了大模型迭代,就是“算力瓶颈”。大家都知道GPU不够用、HBM抢疯了,但很少有人注意到,存储层正在酝酿一场革命——高带宽闪存(HBF)。今天就结合HBM之父Joungho Kim教授的最新观点,跟大家好好盘盘这门技术:它不是HBM的替代品,却可能重塑AI推理的游戏规则,甚至在2038年超越HBM市场规模。先澄清一个核心认知:HBF不是凭空冒出来的新技术,而是站在HBM肩膀上的“优化款”。

存储随笔 2129

LVGL在STM32H743IIT6上的性能优化技巧:如何提升图形界面刷新速度

本文详细介绍了在STM32H743IIT6高性能MCU上优化LVGL图形界面刷新速度的实战技巧。通过利用芯片的DMA2D硬件加速模块替代低效的软件画点,将绘制缓冲区放入SDRAM并启用双缓冲机制,以及合理配置CPU缓存与MPU,有效解决了界面卡顿问题。文章还涵盖了LVGL引擎调优、内存架构优化等关键步骤,帮助开发者充分发挥STM32H743的硬件潜力,实现流畅的图形界面体验。

vscode6remote的博客 306

Codeforces 515D - Drazil and Tiles (拓扑排序)

RT

一只冰熊 963

Eplan P8自动线号生成全攻略:从电位定义点到连接编号的完整流程

本文详细解析了Eplan P8自动线号生成的全流程,从电位定义点的创建配置到连接编号的标准化管理,帮助电气设计人员提升图纸规范性和工作效率。重点介绍了自动编号方案的定义与调整技巧,以及企业级标准化实施建议,是掌握Eplan P8自动线号功能的实用指南。

weixin_29254029的博客 509

HDU_6073 Matching In Multiplication 【二分图&&拓扑排序&&DFS】

题目链接 题目描述如果图中点可以被分为两组,并且使得所有边都跨越组的边界,则这就是一个二分图。准确地说:把一个图的顶点划分为两个不相交集 U 和V ,使得每一条边都分别连接U、V中的顶点。如果存在这样的划分,则此图为一个二分图。二分图的一个等价定义是:不含有「含奇数条边的环」的图完美匹配:如果一个图的某个匹配中,所有的顶点都是匹配点,那么它就是一个完美匹配。但是小Q错误的理解了二分图的定义,以为二分

Learning Deep Learning 396

宇树科技嵌入式面试题及参考答案(春晚机器人的公司)

内存对齐是指在内存中为数据对象分配存储空间时,按照一定的规则将数据存储在特定的地址上,以提高内存访问效率。不同的数据类型在内存中都有其特定的对齐要求,例如,int类型通常要求 4 字节对齐,double类型通常要求 8 字节对齐。这意味着数据的存储地址必须是其对齐字节数的整数倍。如果不进行内存对齐,处理器在访问数据时可能需要进行多次内存访问,从而降低了访问效率。指令可以用于控制结构体内存布局,它允许程序员指定结构体成员的对齐方式。其基本用法是在结构体定义之前使用来指定对齐字节数n,其中n。

大模型大数据攻城狮的专栏 3224

C++多线程 task--std::promise和std::future

本文主要讲解C++11/14/17中所提供的应用于多线程编程中的Task机制。Task可由如下几部分取得而本文主要讲解std::promise和std::future相关的内容。std::promise和std::future通过一个数据管道进行交流,可以将std::promise看作生产者,std::future看作消费者,其两者形成如下的方式交互std::promise本身是一个模版类,通过std::promise可以像数据管道中设置value,异常和相应的通知信息。std::promise提供了如下接

qls315的博客 1818

【Codeforces Round #532 (Div. 2) E. Mahmoud and a xor trip】 二分+拓扑排序

E. Andrew and Taxi 题意 给你一个有边权的有向图,反转一条边的代价是这条边的边权,反转多个边的代价是所有反转边里面边权最大的那条边的边权,问让这个图不存在环的最小代价,以及被反转的边的编号。 做法 首先求最小代价,我们只需要二分这个代价,check就是看删除所有小于这个代价的边之后是否有环。 输出边集,要用到拓扑排序的一个性质 一个图进行拓扑排序后,对于每一个有向边u-&amp;amp;gt;...

lajiyuan的博客 586

046篇:数据统计:分组、求和、平均值、最大最小值

本文介绍了在RPA中实现数据分组统计的方法。通过字典+循环组合,可以完成按单字段或多字段的分组聚合操作,包括求和、计数、求平均值及最大/最小值等。文章详细讲解了分组统计的原理,并提供了单级分组、多级分组的具体实现步骤,最后通过销售数据按月分组的实战案例,演示了如何从原始数据到生成汇总报表的完整流程。这些方法可以灵活应用于各类数据统计分析场景。

weixin_59649563的博客 214

二 图 之 拓扑排序算法、关键路径

1、拓扑排序---主要解决一个工程能否顺序进行  拓扑排序的意义? 举个例子先:一个软件专业的学生学习一系列的课程,其中一些课程必须再学完它的基础的先修课程才能开始。如:在《程序设计基础》和《离散数学》学完之前就不能开始学习《数据结构》。这些先决条件定义了课程之间的领先(优先)关系。这个关系可以用有向图更清楚地表示。图中顶点表示课程,有向边表示先决条件。若课程i是课程j的先决条件,

jyh的博客 772

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Drazil and Tiles - CODEFORCES 515D 贪心

Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover

呼,是出一口气;吸,是争一口气! 886

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces Round #292 (Div. 2) -- D. Drazil and Tiles (拓扑排序)

D. Drazil and Tiles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Drazil created a following problem abou

Never say never 1486

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

[Codeforces515D]Drazil and Tiles(构造)

我和谁都不争,和谁争我都不屑。

zyf2000 1029

CodeForces 825D(贪心)

问题描述:You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.Suitability of string s is calculated by following metric:Any two letters can be swap...

wust_cyl的博客 405

D. Drazil and Tiles (CF 515D bfs搜索)

题意:n*m的图,‘.’表示空格,现在要用1*2的砖去把它填满,可以横向(‘<’,'>')填和竖向('^','v')填。找出基本元素块,(i,j)和它相邻的四个点看成一个基本元素块,如果(i,j)周围的‘.’只有一个那么这个(i,j)处的填法就是固定的,填完(i,j)后看它周围是否有其他点因为填完(i,j)后填法变的唯一,有就入队, 就这样一步一步找到固定填法的(i,j),更新周围的点。

@you! 775

Codeforces Round #532 (Div. 2) E. Andrew and Taxi(二分+拓扑排序)

题目链接 题意 给你一个图1-n标号,m条有向边。 每条有向边有一个权值,代表翻转其方向所需代价。 求使得图变成无环图,翻转边权的最大值最小。 思路 二分答案,判断权值大于答案的边集是否能成环,如果不能说明答案可以再小点,否则答案可以大点。 关键是翻转哪些边比较难想,第一次感受到拓扑排序,排序二字用处。 按拓扑排序的顺序,给每个点从小到大赋权,最后判断如果起点权值大于终点权值则需要翻转。画个图就明...

←_← 1297

【python数据结构】二分图、拓扑排序、并查集

1.判断是否为二分图【leetcode785】 如果可以用两种颜色对图中的节点进行着色,并且保证相邻的节点颜色不同,那么这个图就是二分图。 class Solution: def isBipartite(self, graph: List[List[int]]) -> bool: color = {} for node in range(len(graph)): if node not in color:

original_recipe的博客 445

Drazil and Tiles CodeForces - 515D

Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover ...

dsaghjkye的博客 260

CodeForces 825E Educational #25 E:拓扑排序+优先队列

题意:给出一个图,有N(v表示v的权值要大于u的,这样n个点赋值完成后,形成一个n的全排列。要求所有合法的全排列中字典序最小的一个。 题解:我们手上有若干联通快,每个联通快要满足一定的内在大小关系,拿出一个联通快单独看,肯定不会出现环路,因为这样必然形成大于关系的矛盾,那么必然存在一些点出度=0,而这些点就是这个联通快里边的“极大值点”(说法并不是很准确,意会即可),那么我们首先可以通过判断出度

辣鸡葫芦娃 591

HDU - 5438 - Ponds (拓扑排序)

题意: 删除入度为一或零的所有池塘,最后求所有联通快内点的数量是奇数的value和。 #include &lt;bits/stdc++.h&gt; using namespace std; typedef long long ll; const int maxn = 1e4 +100; int vis[maxn],degree[maxn];//是否访问,以及该点的入度 int val[max...

刘二狗的博客 274

【CF 515D】 Drazil and Tiles

【CF 515D】 Drazil and Tiles 拓扑的思想 如果满足条件 ‘.’未遍历完之前肯定存在度为1的点(上下左右仅有一个’.’)遍历到一个1度点u时 将与他连的点v用对应括号括起 此时v也已匹配 入度归零 同时将与v相连的其余点入度减1 不断遍历知道遍历完所有’.’ 若能遍历完 则满足条件否则无解或多解 (吐槽一下 原本用的纯粹拓扑思路 想想也是绝对要T的。。后来改换BFS代码如下:

ACMer' 1074

Codeforces-1100E:Andrew and Taxi(二分+拓扑排序)

E. Andrew and Taxi time limit per test 2 seconds memory limit per test 256 megabytes inputstandard input outputstandard output Andrew prefers taxi to other means of transport, but recently most taxi d...

Mitsuha_的博客 1239
上一篇: zoj 3686 树转化为数组表示,线段树区间更新
下一篇: codforeces 527D 贪心
HuanTongH
博客等级 码龄12年 7粉丝 110原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值