Codeforces 631B Print Check (思维)
题目链接 Print Check
注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了。
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i(a); i <= (b); ++i)
const int N = + ;
const int Q = + ; struct node{
int op, x, y;
} a[N]; int col[Q][Q];
int v[N]; //v[i] = 1 则第i个操作需要被执行
int c[][Q];
int n, m, k, op, x, y; int main(){ scanf("%d%d%d", &n, &m, &k);
rep(i, , k){
scanf("%d%d%d", &op, &x, &y);
c[op][x] = i;
a[i].op = op, a[i].x = x, a[i].y = y;
} rep(i, , n) if (c[][i]) v[c[][i]] = ;
rep(i, , m) if (c[][i]) v[c[][i]] = ; rep(i, , k) if (v[i]){
if (a[i].op == ){
rep(j, , m) col[a[i].x][j] = a[i].y;
}
else{
rep(j, , n) col[j][a[i].x] = a[i].y;
}
} rep(i, , n){
rep(j, , m) printf("%d ", col[i][j]);
putchar();
} return ; }
Codeforces 631B Print Check (思维)的更多相关文章
- CodeForces 631B Print Check
对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; ...
- Codeforces 631B Print Check【模拟】
题意: 按顺序给定列和行进行涂色,输出最终得到的方格颜色分布. 分析: 记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色. 代码: #include<iostream> ...
- CodeForces 631C Print Check
排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm ...
- codeforces 631B B. Print Check
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 ...
- 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 ...
- 存储构造题(Print Check)
连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次: ...
- Maximal GCD CodeForces - 803C (数论+思维优化)
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- HDU1301 Jungle Roads
Jungle Roads The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign ai ...
- sql中over的用法
over不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用.其参数:over(partition by columnname1 order by c ...
- 图学java基础篇之集合
(本文部分图片引用自其他博客,最后有链接,侵删.由于笔记使用markdown记录,格式可能不是太好看,见谅) 集合结构 红字为java.util包下的,绿字为concurrent包下扩展的与并发相关的 ...
- laravel5.2总结--数据填充
1 生成一个seeder文件 你可以通过 make:seeder artisan命令来生成一个 Seeder.所有通过框架生成的 Seeder 都将被放置在 database/seeds 路径: ...
- Form 组件动态绑定数据
1.Form 组件的作用: a.对用户提交的数据进行验证(form表单/ajax) b.保留用户上次输入的信息 c.可以生成html标签(input表单类的标签) 2..由于form组件中每个字段都是 ...
- hnust 聚宝盆
问题 A: 聚宝盆 时间限制: 1 Sec 内存限制: 128 MB提交: 663 解决: 282[提交][状态][讨论版] 题目描述 Grace是个善良的同学,他经常帮助同学解决问题.这天,他正 ...
- Adaboost和GBDT的区别以及xgboost和GBDT的区别
Adaboost和GBDT的区别以及xgboost和GBDT的区别 以下内容转自 https://blog.csdn.net/chengfulukou/article/details/76906710 ...
- 【SPOJ1297】Palindrome (SA+RMQ)
求最长回文串.把原串翻转后,加在原串后面,中间插入一个辨别字符.然后求SA,Height.然后枚举每个字母作为回文串中心,分长度为奇数和偶数去讨论:奇数求 suffix(i)和suffix(n-i+1 ...
- vue的roter使用
1在src下建立router文件夹,再建立router.js import Vue from 'vue' import Router from 'vue-router' import home fro ...
- python网络
try: import urllib.request as urllib2 except ImportError: import urllib2 response = urllib2.urlopen( ...