写程序手不稳是个大毛病,往往会让一份能AC的代码变成99.995%正确,失之毫厘谬以千里,近期十场个人赛非常少有能一次AC的经历,细致想想除了根本逻辑上的错误.大概都是跪在这些细节上: 1.输出格式,输入格式是否符合规范.有没有Case #?是否有多余空格输出?I64d or lld?输出浮点数尽量不要用cout. 2.i和j,n和m,l和r有没有写混了的..(今晚检查了两小时的程序发现i<=m写成了i<=n...吾之内心差点儿崩溃orz. . 3.边界问题.从0開始还是从1開始?递推式有没有…
Can you answer these queries II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 https://www.spoj.com/problems/GSS2/ Description Being a completist and a simplist, kid Yang Zhe cannot solve but get Wrong Answer from most of the OI problems. And he refuse…
Given a tree with N ( N<=100000 ) nodes. Each node has a interger value x_i ( |x_i|<=10000 ). You have to apply Q ( Q<=100000 ) operations: 1. 1 a b : answer the maximum contiguous sum (maybe empty,will always larger than or equal to 0 ) from the…
2482: [Spoj1557] Can you answer these queries II Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 145  Solved: 76[Submit][Status][Discuss] Description 给定n个元素的序列. 给出m个询问:求l[i]~r[i]的最大子段和(可选空子段). 这个最大子段和有点特殊:一个数字在一段中出现了两次只算一次. 比如:1,2,3,2,2,2出现了3次,但只算一次,…
1557. Can you answer these queries II Problem code: GSS2 Being a completist and a simplist, kid Yang Zhe cannot solve but get Wrong Answer from most of the OI problems. And he refuse to write two program of same kind at all. So he always failes in co…
Can you answer these queries III SPOJ - GSS3 这道题和洛谷的小白逛公园一样的题目. 传送门: 洛谷 P4513 小白逛公园-区间最大子段和-分治+线段树区间合并(单点更新.区间查询) 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1…
错误原因: 1.在递归的时候,递归函数中忘记加返回return. 1.1做题时遇到一个奇葩错误,把它记到这里,看代码: 代码1:错误,用c++提交wrong answer,但是用g++提交却accepted. int set_find(int d) { if(set[d]<0) return d; set_find(set[d]);//这里递归时没有返回值,只有在结束条件时返回(即最后一层递归有返回值,前面的没有返回值) } 上述代码在进行递归的时候,只有在递归结束时的最后一层返回一个值d,但是…
F2. Wrong Answer on test 233 (Hard Version) Your program fails again. This time it gets "Wrong answer on test 233" . This is the harder version of the problem. In this version, 1≤n≤2⋅105. You can hack this problem if you locked it. But you can h…
原题链接: Find the answer c++中,multiset是库中一个非常有用的类型,它可以看成一个序列,插入一个数,删除一个数都能够在O(logn)的时间内完成,而且他能时刻保证序列中的数是有序的,而且序列中可以存在重复的数. 具体操作请参考: multiset用法总结 解题思路:对于1007这道题,当放一个数x的时,先模拟判断,再插入序列中,进行合法判断,如果一个数不合法,则将它删去,为什么可以删去呢?因为一个数如果被判断不合法的话,那么接下来他也不会再被用了. 代码如下: #in…
  A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of endurance. For every attack of our secret weapon, i…