题目链接:http://www.spoj.com/problems/IM/en/ Time limit:491 ms Memory limit:1572864 kB Code length Limit:50000 B Jedi knights, Qui-Gon Jinn and his young apprentice Obi-Wan Kenobi, are entrusted by Queen Padmé Amidala to save Naboo from an invasion by th…
http://www.spoj.com/problems/IM/ 962. Intergalactic Map Problem code: IM Jedi knights, Qui-Gon Jinn and his young apprentice Obi-Wan Kenobi, are entrusted by Queen Padmé Amidala to save Naboofrom an invasion by the Trade Federation. They must leave N…
Intergalactic Map Time Limit: 6000ms Memory Limit: 262144KB This problem will be judged on SPOJ. Original ID: IM64-bit integer IO format: %lld Java class name: Main Jedi knights, Qui-Gon Jinn and his young apprentice Obi-Wan Kenobi, are entrus…
Jedi knights, Qui-Gon Jinn and his young apprentice Obi-Wan Kenobi, are entrusted by Queen Padmé Amidala to save Naboofrom an invasion by the Trade Federation. They must leave Naboo immediately and go to Tatooine to pick up the proof of the Federatio…
ADAFIELD - Ada and Field 这个题,如果用一个字来形容的话:-----------------------------------------------嗯! 题意:n*m的空白矩形坐落在XY轴,Q次操作,每次可以在y轴或x轴的矩形区域内画一条直线,是直线啊.问每次操作后最大的矩形面积多大. 对于思路我只能拍手称赞了,一开始想不到怎么优化,想着用优先队列或set来存当前边的最大值,但是更新的时候却 无法实时更新.赛后看其他选手的代码才突然想到可以用map的键值来排序,每次插…
Coding a Dijkstra is not hard. %70 of my time spent on tackling TLE, as my last post. Dijkstra works in BFS manner, but at each step, it picks the shortest child greedily and then relax all other neighbors. Data Structure: since there could be up to…
Just CS rookie practice on DFS\BFS. But details should be taken care of: 1. Ruby implementation got TLE so I switched to C++ 2. There's one space after each output node, including the last one. But SPOJ doesn't clarify it clearly. #include <iostream>…
GSS7Can you answer these queries VII 给出一棵树,树的节点有权值,有两种操作: 1.询问节点x,y的路径上最大子段和,可以为空 2.把节点x,y的路径上所有节点的权值置为c 分析: 修改树路径的信息,可以考虑一下树链剖分.动态树. 这题可以用树链剖分的方式来做,不会的可以看看这篇 树链剖分---模板.其实树链剖分不难理解,一小时左右就能学会了. 对于在一段区间的最大子段和问题,可以参考GSS1 spoj 1043 Can you answer these qu…
题目链接 题意:n个数 m个查询 查询的是[l, r]区间内不相同的数的个数 没有修改,因此静态的主席树就好了 将重复的元素建树即可 query的时候加起来,用区间长度(r-l+1)去减就是答案 (query的是[l, r]之间重复元素的个数) typedef long long LL; #define lson l, m #define rson m+1, r ; ], R[N<<], sum[N<<]; int tot; int a[N], T[N]; int read() {…
4487. Can you answer these queries VI Problem code: GSS6 Given a sequence A of N (N <= 100000) integers, you have to apply Q (Q <= 100000) operations: Insert, delete, replace an element, find the maximum contiguous(non empty) sum in a given interval…
http://www.spoj.com/problems/SEGSQRSS/ SPOJ Problem Set (classical) 11840. Sum of Squares with Segment Tree Problem code: SEGSQRSS Segment trees are extremely useful. In particular "Lazy Propagation" (i.e. see here, for example) allows one to c…
Count on a tree Time Limit:129MS Memory Limit:1572864KB 64bit IO Format:%lld & %llu Submit Status Practice SPOJ COT Description You are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight. We will…