CodeForces 705C Thor (模拟+STL)】的更多相关文章

题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记是哪个应用产生的,用set来记录是第几个通知. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include &l…
开30W个vector将数字归类,每一类数字开一个指针P,记录已经阅读到哪一个了,还可以开一个优先队列维护这些指针P. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<…
201612-3 试题名称: 权限查询 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 授权 (authorization) 是各类业务系统不可缺少的组成部分,系统用户通过授权机制获得系统中各个模块的操作权限. 本题中的授权机制是这样设计的:每位用户具有若干角色,每种角色具有若干权限.例如,用户 david 具有 manager 角色,manager 角色有 crm:2 权限,则用户 david 具有 crm:2 权限,也就是 crm 类权限的第 2 等级的权限. 具体地…
[Codeforces 1246B] Power Products (STL+分解质因数) 题面 给出一个长度为\(n\)的序列\(a_i\)和常数k,求有多少个数对\((i,j)\)满足\(a_i \times a_j = x^k (x \in \mathbb{N}^+)\).即这两个数乘起来恰好为一个正整数的\(k\)次方 \(a_i,n \leq 10^5\) 分析 考虑\(x^k\)的质因数分解式 , 那么每一项的指数一定是k的倍数,即 \(k|x_i\). 因此对于每个 \(a_i\)…
题目链接: http://codeforces.com/problemset/problem/704/A http://codeforces.com/problemset/problem/705/C 题目大意: 雷神有N个应用,接下来Q个操作,操作分三种 1.应用X增加一个未读消息. 2.把应用X的未读消息全都读了.(可能重复读了已读的) 3.把前X个1操作的未读消息全都读了.(可能重复读了已读的) 求每一个操作后当前的未读消息总数. 题目思路: [模拟] 一开始看错题目,以为操作二是把后X个消…
题目链接: 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…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
http://codeforces.com/contest/705/problem/C 题目 模拟题 : 设的方法采用一个 r 数组(第几个app已经阅读过的消息的数量),和app数组(第几个app发出的消息的总数),加上一个 q 队列. 思路: 查询==1的时候,入队(记录顺序), sum++ (sum 为全部的剩余 没阅读的数量) 查询==2的时候,针对一个app,sum -(这个app发出的消息的总数 - 这个app已经阅读过的消息的数量),然后用 app数组 更新 r 数组,表示这个ap…
题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡内存--详细看代码. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h&g…
B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome mons…
题目:这里 题意:n个app,q个操作,当操作数type为1的时候表示y这个app推送了你一条消息,当操作数type为2的时候表示将y这个app已推送的所有消息都读完,当操作数为3的时候 表示将已经推送的前(按推送的时间顺序)y条消息再读一遍(不管这前y条消息中有没有读过的,都再读一遍),问每次操作的时候的未读的消息数是多少? 用队列来模拟就好,记得每次要输出的是所有app的没有读过的消息的总数就行,不要想的太细,把读过的标记一下就行,总是觉得这个会超时,但是一想这才是2的第三题,1 的第一题,…
题目链接:点击打开链接 题意: 给定n*m的矩阵.k个操作 2种操作: 1.H x 横向在x位置切一刀 2.V y 竖直在y位置切一刀 每次操作后输出最大的矩阵面积 思路: 由于行列是不相干的,所以仅仅要知道每次操作后行的最大间距和列的最大间距,相乘就是最大面积 用一个set维护横向的全部坐标点,一个multiset维护横向的间距. 每次对行操作x则在set中找到比x大的最小数 r 和比x小的最大数l ,操作前的间距dis = r-l.在multiset中删除dis并插入r-x 和x-l.再在s…
C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodi…
题目链接:http://codeforces.com/problemset/problem/799/B 题目大意:有n件T恤,每件T体恤都分别有价格(每件衣服的价格不重复).前面的颜色.背部的颜色三种属性.接下来有m个人每个人都有一种喜欢的颜色,他们按先后顺序选择衣服,如果没有喜欢的颜色的衣服了就输出“-1”,否则选择其中符合条件的衣服中价值最小的.输出每个人要付出的钱. 解题思路:使用c++STL里的set(会自动按照从小到大的顺序排好,不存在重复),设置set[1],set[2],set[3…
Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a s…
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding - an active marketing strategy, that includes a set of measures to change either the bra…
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can…
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know th…
描述 中学数学里集合的元素往往是具体的数字,比如A = {1,2,3},B = {}(空集)等等.但是要特别注意,集合的元素也可以是另一个集合,比如说C = {{}},即说明C有且仅有一个元素--空集B,所以称B是C的子集或者称B是C的元素都是正确的.所谓一个集合的势,就是这个集合的元素个数,一般记为|S|,空集的势为0.在上例中,|A| = 3,|B| = 0,|C| = 1. 鉴于集合论是现代数学的基础理论这一事实,一群异想天开的科学家开始着手建造一台新式的超级计算机--集合堆栈机Alpha…
活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int>PII; const double eps=1e-5; const double pi=acos(-1.0); //const int mod=1e9+7; const int INF=0x3f3f3f3f; //ht…
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 napplications on this phone. Thor is fascinated b…
我们在理解stack和queue的基础上可以用数组来代替这两个容器,因为STL中的stack和queue有可能会导致程序运行起来非常的慢,爆TLE,所以我们使用数组来模拟他们,不仅可以更快,还可以让代码更加简洁 1.数组模拟stack #include <iostream> #include <cstdio> #include <cstring> #include <string.h> #include <math.h> #include <…
题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...…
题目链接:CodeForces #100  C 题意:现在给出n个snowball的半径,3个半径严格递增或递减的snowball,可以组成1个snowmen.问最多能组成多少个snowmen.并且按照半径递减的顺序输出每个snowmen的组成. 思路:嗯...每次都从前三个个数最多的snowball里选择,最后组成的snowmen最多... ...可以用优先队列写..但是感觉set+map写的太优雅了...map当然不等于数组了...哼. #include <stdio.h> #includ…
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4241    Accepted Submission(s): 2164 Problem Description ACboy was kidnapped!! he miss his mother very much and is ve…
UVA 246 - 10-20-30 题目链接 题意:给52张的扑克堆,先从左往右发7张牌,之后连续不断从左往右发7张牌,假设有牌堆形成了下面3种情况(按顺序推断): 1.头两张+尾一张和为10或20或30 2.头一张+尾两张和为10或20或30 3.尾三张和为10或20或30 就把这三张牌拿走,放到总牌堆底(这步要不断运行直到不再满足条件或牌堆没了) 假设有一个牌堆由于这个操作被取完了,那么以后将不在这个位置发牌. 假设最后7个牌堆都能够消掉,那么赢,总牌堆用完,那么输,否则平(即不断循环)…
强行模拟 纪念一下…… #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<map> #include<vector> #include<queue> #define M(a,b) memset(a,b,sizeof…
题目大意:给出n个点的坐标,和你当前的坐标,求走过n-1个点的最短路程. 题目思路:走过n-1个点,为了使路程更短,那么不走的点只可能第一个点或最后一个点.模拟就行了,比较恶心. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h> #include<queue&…
A. Snacktower time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
贪心策略: 1.只有一个最大值,选着第二大的一起参加比赛减分. 2.有奇数个最大值,选择三个进行比赛. 3.偶数个最大值,选择两个进行比赛. 为什么不把最大值全部选择? 因为最多只能选五个,有可能选择完五个只剩下一个最大值,那么就会进行贪心策略1,会出错. AC代码: #include<cstdio> #include<set> using namespace std; const int maxn=1e4+1; char ans[maxn][101]; int cnt=0,n;…