【题解】CF631B Print Check
题面传送门
解决思路:
首先考虑到,一个点最终的情况只有三种可能:不被染色,被行染色,被列染色。
若一个点同时被行、列染色多次,显示出的是最后一次被染色的结果。所以我们可以使用结构体,对每一行、每一列记录下其最后一次被染色的颜色和时间。因为同行或同列反复染只有最后一次有影响,所以后来的直接覆盖之前的即可。
一个点的最终结果:若最后一次染行晚于最后一次染列,则显示最后一次染行的颜色,反之显示最后一次染列的颜色。
然后程序就很简单了。
AC Code:
#include<bits/stdc++.h>
using namespace std;
int n,m,k,op,a,b;
struct node{
int val,time;
}x[5005],y[5005];
int main(){
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m>>k;
for(int i=1;i<=k;i++){
cin>>op>>a>>b;
op==1?x[a]={b,i}:y[a]={b,i};
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) cout<<(x[i].time<y[j].time?y[j].val:x[i].val)<<' ';
cout<<endl;
}
return 0;
}
【题解】CF631B Print Check的更多相关文章
- Codeforces Round #344 (Div. 2) B. Print Check 水题
B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a lar ...
- Codeforces Round #344 (Div. 2) B. Print Check
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 存储构造题(Print Check)
连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次: ...
- codeforces 631B B. Print Check
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces 631B Print Check (思维)
题目链接 Print Check 注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了. #include <bits/stdc++.h> ...
- Codeforces Round #344 (Div. 2) 631 B. Print Check (实现)
B. Print Check time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...
- CodeForces 631B Print Check
对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; ...
- CodeForces 631C Print Check
排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm ...
- Codeforces 631B Print Check【模拟】
题意: 按顺序给定列和行进行涂色,输出最终得到的方格颜色分布. 分析: 记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色. 代码: #include<iostream> ...
随机推荐
- openstack中Nova组件简解
一.Nova组件概述 计算节点通过Nova Computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,nova之间通信通过rabbitMQ队列进行通信. Nova位于Openstack架 ...
- VS Code中Markdown常用插件
目录 目录 1.Markdown All in One 2.Markdown Preview Enhanced 3.markdownlint 1.Markdown All in One 自动生成目录 ...
- PostgreSQL 大对象导出报错问题分析
1.前言 在处理用户问题过程遇到一个问题.用户通过pg_dump导出 bytea 对象时,当行的大小超过 1G时,会报错: [v8r6c5b41@dbhost01 ~]$ sys_dump -t t1 ...
- vacuum和vacuum full的处理过程
对于数据库系统的并发控制,KingbaseES采用MVCC(多版本并发控制)进行处理. 这种机制有一个缺点,就是随着时间的推移,数据文件中积累的dead tuples会越来越多. 怎么去清理这些dea ...
- torch.sort 和 torch.argsort
定义 torch.sort(input,dim,descending) torch.argsort(input,dim,descending) 用法 torch.sort:对输入数据排序,返回两个值, ...
- Grafana Mimir:支持乱序的指标采集
Grafana Mimir:支持乱序的指标采集 译自:New in Grafana Mimir: Introducing out-of-order sample ingestion 很早之前在使用th ...
- 华南理工大学 Python第7章课后小测-2
1.(单选)以下选项中使Python脚本程序转变为可执行程序的第三方库的是(本题分数:3)A) NetworkxB) pyinstallC) RequestsD) PyPDF2您的答案:B 正确率: ...
- CentOS7使用yum方式安装Containerd
# 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的 yum install -y yum-utils device-m ...
- SC命令---安装、开启、配置、关闭windows服务 bat批处理
一.直接使用cmd来进行服务的一些操作 1.安装服务 sc create test3 binPath= "C:\Users\Administrator\Desktop\win32srvDem ...
- Portainer 安装MySQL并开启远程访问
进入到 Portainer 页面,选择左边的 Containers 选项,单击上方的 Add container 按钮转到如图所示的页面: 1.在 Name 一栏中输入容器名字: 2.在 Image ...