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) + ; + ; struct node{ int op, x, y; } a[N]; int col[Q][Q]; int v[N]; //v[i] = 1 则第i个…
题意: 按顺序给定列和行进行涂色,输出最终得到的方格颜色分布. 分析: 记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色. 代码: #include<iostream> #include<cstdio> using namespace std; const int maxn = 5005; int num[maxn][maxn]; int ma[2][maxn]; int ro[maxn], ca[maxn]; int main (void) { int n,…
对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; +]; +]; int main() { scanf("%d%d%d",&n,&m,&k); memset(high,-,sizeof high); ;i<=k;i++) scanf("%d%d%d",&op[i],&id[…
排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; + ; int n, m; int a[maxn], ans[maxn]; int op[maxn], e[maxn]; int pos[maxn]; int first, last; int flag; int p; int tot; bool cmp(c…
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a…
B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizon…
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a…
B. Print Check time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a pri…
连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次:没有必要用for每个数据涂一遍. 所以如果能一次直接涂一行就可以了: #include <iostream> #include <cstdio> uising namespace std; #define N 5005 ; typedef long long LL; int row[N…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships…
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U'…
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, b…
题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人只能打招呼一次). 例: 输入:31 1 105 8 29 9 10 输出: 2 1 1 解题思路:先按行走的开始时刻排下序,然后直接模拟判断和比他后出现的人是否可以相遇. 第一步判断前面那个人在未走完前,下一人会出现,若不出现,直接break.然后就计算当下一个人出现的时刻,前一个人的位置,然后又…
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: standard input output: standard output You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation".…
A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of ca…
题目链接:http://codeforces.com/problemset/problem/2/A A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output The winner of the card game popular in Berland "Berlogging" is determined acc…
CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecules Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u id=46665" class="login ui-button ui-widget ui-state-default…
题目链接: C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fasci…
id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" style="color:blue; text-decoration:none">Alternating Current Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64…
题意:给定一个序列,现在你每次至多给5个人的权值减小1,最少2个人,最小是0,使得剩下的所有权值都相等且尽量大. 析:用multiset来模拟,每次取权值最大的三个或者两个,直到最后相等.我开始没有这个STL,自己写的,虽然过了,但是好麻烦,后来看的题解是用这个. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #i…
A. Face Detection time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are cu…
http://codeforces.com/contest/752/problem/B uuu yyu xy xx 注意变化了之后,检查一次前面已经变化过的就好.因为可能前面的满足,但是变了后不满足. #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <assert.h> #def…
题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡内存--详细看代码. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h&g…
E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can re…
大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #inc…
A. Extract Numbers time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and '…
Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如何处理这个第二个操作呢? 对于一个数a,如果模数 x > a ,则这次取模是没有意义的,直接跳过: 如果 x > a/2 ,则取模结果小于 a / 2; 如果 x < a / 2,取模结果小于x,则也小于 a / 2. 所以对于一个数,最多只会做log a次取模操作.这是可以接受的! 对于一…
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is…
[题目链接]click here~~  [题目大意]:  You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).  Input  The only line of input contains a…
注意到R和C只与最后一个状态有关 /*H E A D*/ struct node2{ int kind,las,val,pos; node2(){} node2(int k,int l,int v,int p){ kind=k;las=l; val=v;pos=p; } }b[maxn]; bool cmp(node2 a,node2 b){ return a.las<b.las; } int mt[5003][5003]; int main(){ int n,m,k,op; while(~ii…