CF433B Kuriyama Mirai's Stones 题解】的更多相关文章

Content 有一个长度为 \(n\) 的数组 \(a_1,a_2,a_3,...,a_n\).有 \(m\) 次询问,询问有以下两种: \(1~l~r\),求 \(\sum\limits_{i=l}^ra_i\). \(2~l~r\),将数组非降序排列后再依次标号,然后再求 \(\sum\limits_{i=l}^ra_i\). 数据范围:\(1\leqslant l\leqslant r\leqslant n\leqslant 10^5,1\leqslant m\leqslant 10^5…
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: She wi…
题目简单描述就是求数组中[l,r]区间的和 #include <iostream> #include <vector> #include <string> #include <algorithm> #include <numeric> using namespace std; int main(){ int n,m; cin >> n; vector<,); ; i <= n ; ++ i) cin >> v[…
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: She wi…
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are no…
题面 官方题解 模拟赛题解 题解概述: 定义符号A~B表示序列A是序列B的子序列,A!~B反之. 设操作序列为I,则有A~I,B!~I,C~I,D!~I. 可得出条件①B!~C且D!~A,所以我们只要讨论满足这个条件的情况. 分情况讨论: c1=c2,则可以进行操作c1,得到的状态仍满足条件①: c1!=c2,且B'!~C,此时可以进行操作c1: c1!=c2,且D'!~A,此时可以进行操作c2: c1!=c2,且D'~A,B'~C,此时无法进行操作,此情况无解: 我们还发现第4种情况下,B=.…
题目链接:http://www.hihocoder.com/problemset/problem/1636 题目描述 在中国古代神话中,盘古是时间第一个人并且开天辟地,它从混沌中醒来并把混沌分为天地. 刚开始地上是没有山的,只有满地的石头. 这里有 \(N\) 堆石头,标号为从 \(1\) 到 \(N\) .盘古想要把它们合成一堆建造一座大山.如果某些堆石头的数量总和是 \(S\) ,盘古需要 \(S\) 秒才能把它们合成一堆,这新的一堆石头的数量就是 \(S\) . 不幸的是,每一次盘古只能把…
比赛链接:http://codeforces.com/contest/433 A. Kitahara Haruki's Gift time limit per test:1 second memory limit per test:256 megabytes Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between th…
Kuriyama Mirai's Stones CodeForces - 433B 有n颗宝石,每个宝石都有自己的价值. 然后m次询问.问区间[i,j]的宝石的总值,或者问排序后的区间[i,j]的总值. Input第一行输入一个n(1 <= n <=10^5),表示n个宝石 第二行n个数,v1, v2, ..., vn (1 ≤ vi ≤ 10^9) ,表示每个宝石的价值 第三行输入询问次数m(1≤m≤10^5). 然后m行,每行包含三个整数类型,type.l和r( 1 ≤ l ≤ r ≤n:…
题解 A AND Minimum Spanning Tree 参考代码: #include<bits/stdc++.h> #define maxl 200010 using namespace std; int n,ans1; ]; int ans[maxl]; inline void prework() { scanf("%d",&n); } inline int find(int x) { ;j<=;j++) ) return mi[j]; } inlin…
Hash Table基础 哈希表(Hash Table)是常用的数据结构,其运用哈希函数(hash function)实现映射,内部使用开放定址.拉链法等方式解决哈希冲突,使得读写时间复杂度平均为O(1). HashMap(std::unordered_map).HashSet(std::unordered_set)的原理与Hash Table一样,它们的用途广泛.用法灵活,接下来侧重于介绍它们的应用. 相关LeetCode题: 706. Design HashMap  题解  705. Des…
目录 题目 口胡题解 题目 有许多的青蛙要过河,可惜的是,青蛙根本跳不过河,他们最远只能跳 \(L\) 单位长度,而河宽 \(W\) 单位长度. 在河面上有一些石头,距离 \(i\) 远的地方有 \(a_i\) 个石头,每个石头只能使用一次,求最大能有多少青蛙过河. 输入的第一行为两个整数 \(W,L(1<l<w<10^5)\) 第二行有 \(W-1\) 个整数 \(a_1,a_2.......a_{w-1}(0<a_i<10^4)\) 输出为一个整数,即能过河的最大青蛙数…
题意:合并石子,每次只能合并l~r堆成1堆,代价是新石堆石子个数,问最后能不能合成1堆,不能输出0,能输出最小代价 思路:dp[l][r][t]表示把l到r的石堆合并成t需要的最小代价. 当t == 1时,dp[i][j][1] = min(dp[i][j][1], dp[i][k][t] + dp[k + 1][j][1] + sum[j] - sum[i - 1]),其中t属于[l - 1, r - 1] 当t >= 2时,dp[i][j][t] = min(dp[i][j][t], dp[…
1.题目描述 2.分析 使用HashTable 是解决这种的好方法. 3.代码 int numJewelsInStones(string J, string S) { map<char,int> m; for(char c : S) m[c]++; ; for( char c: J) ans += m[c]; return ans; }…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5973 Game of Taking Stones Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 Two people face two piles of stones and make a game. They take turns to take stones. As ga…
Colored stones Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1759 Accepted: 829 Description You are given a row of m stones each of which has one of k different colors. What is the minimum number of stones you must remove so that no two…
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对应的随笔下面评论区留言,我会及时处理,在此谢过了. 过程或许会很漫长,也很痛苦,慢慢来吧. 编号 题名 过题率 难度 1 Two Sum 0.376 Easy 2 Add Two Numbers 0.285 Medium 3 Longest Substring Without Repeating C…
题目链接: http://acm.whu.edu.cn/land/problem/detail?problem_id=1538 Problem 1538 - B - Stones II Time Limit: 1000MSMemory Limit: 65536KB 问题描述 Xiaoming took the flight MH370 on March 8, 2014 to China to take the ACM contest in WHU. Unfortunately, when the…
这是 meelo 原创的 IEEEXtreme极限编程大赛题解 IEEEXtreme全球极限编程挑战赛,是由IEEE主办,IEEE学生分会组织承办.IEEE会员参与指导和监督的.IEEE学生会员以团队为单位参与的全球性竞赛,参赛者要在24小时内完成一系列程序设计问题.竞赛自2007年起每年10月份举办一次,迄今为止已经举办9届,参赛规模不断扩大,去年已吸引全球2400多支队伍参赛. 参赛者必须是IEEE学生会员,参赛者以队为单位参加,每个队至多包含3名IEEE学生会员,其中最多有2名研究生.每支…
题目链接: http://acm.whu.edu.cn/land/problem/detail?problem_id=1537 Stones I Time Limit: 1000MSMemory Limit: 65536KB 问题描述 Xiaoming took the flight MH370 on March 8, 2014 to China to take the ACM contest in WHU. Unfortunately, when the airplane crossing t…
这是 meelo 原创的 IEEEXtreme极限编程大赛题解 Xtreme 10.0 - Game of Stones 题目来源 第10届IEEE极限编程大赛 https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/game-of-stones-1-1 Alice and Bob play a game. The game is turn based: Alice moves first, then Bob, a…
Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^(k-1)+a2*b^(k-2)+...+ak*b^0的奇偶性. 题解: 暴力求模2意义下的值就好了. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int n; int b,k; int a[…
Gem Stones John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase latin letter from 'a' to 'z'. An element can be present multiple times in a rock. An element is called a 'gem-elem…
题目描述: Two people face two piles of stones and make a game. They take turns to take stones. As game rules, there are two different methods of taking stones: One scheme is that you can take any number of stones in any one pile while the alternative is…
E. Game of Stones   Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: The game starts with n piles of stones indexed from 1 to n. The i…
Yet Another Game of Stones 题意: Alice 和 Bob 在进行取石子游戏, 现在一共有n堆石子, 每堆石头有ai个, 然后每堆石头有一个bi属性, 如果bi == 0, Alice取这堆石头就没有限制, 如果bi == 1 那么Alice对这堆石子一次只能取奇数个, 如果bi == 2那么Alice 对这堆石头一次只能取奇数个, 所有石头堆对于Bob来说说取法都没有限制. 题解:首先我们可以知道 如果存在一个 a = 1, b = 2. 那么Alice无法取这堆,…
原题链接在这里:https://leetcode.com/problems/minimum-cost-to-merge-stones/ 题目: There are N piles of stones arranged in a row.  The i-th pile has stones[i] stones. A move consists of merging exactly K consecutive piles into one pile, and the cost of this mov…
原题链接在这里:https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/ 题目: On a 2D plane, we place stones at some integer coordinate points.  Each coordinate point may have at most one stone. Now, a move consists of removing a stone that…
Codeforces Round #557 题解 掉分快乐 CF1161A Hide and Seek Alice和Bob在玩捉♂迷♂藏,有\(n\)个格子,Bob会检查\(k\)次,第\(i\)次检查第\(x_i\)个格子,如果Alice在这个格子就输了.Alice一开始会在一个格子,可以在Bob检查过一次后向一个相邻的格子移动(整局游戏只能用一次).求Alice有多少种方案赢. 两个方案相同当且仅当Bob检查之前Alice的位置和Bob做完所有检查之后Alice的位置都相同. cao,sb阅…
Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He woke up from an egg and split the egg into two parts: the sky and the earth. At the beginning, t…