Codeforces 19.E Fairy】的更多相关文章

E. Fairy time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy lo…
题目链接:http://codeforces.com/contest/19/problem/D 题意:给出3种操作:1)添加点(x,y),2)删除点(x,y),3)查询离(x,y)最近的右上方的点. 且满足添加的点不重复,删除的点一定存在. 题解:只要以x建树,记录下每个结点最大的y值.每次都更新一下.用线段树查找满足条件的最小的x,然后用一个set[x]来存x点下的y点. 然后用二分查找满足条件的最小的y. #include <iostream> #include <cstring&g…
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there liv…
I.Yet another A + B You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct? Input There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10100), each on a separate line of input. O…
G.LCS Revised   The longest common subsequence is a well known DP problem: given two strings A and B, one has to compute the maximum length of a subsequence that's common to both A and B. In this particular problem we work with strings A and B formed…
E - Restore Given a matrix A of size N * N. The rows are numbered from 0 to N-1, the columns are numbered from 0 to N-1. In this matrix, the sums of each row, the sums of each column, and the sum of the two diagonals are equal. For example, a matrix…
题目链接:http://codeforces.com/contest/797 A题 题意:给出两个数n, k,问能不能将n分解成k个因子相乘的形式,不能输出-1,能则输出其因子: 思路:将n质因分解,若质因子数目对于k则可行,随便将其组合成k个因子即可,反之则不行: 代码: #include <bits/stdc++.h> using namespace std; const int MAXN=1e5; int a[MAXN]; int main(void){ ; cin >> n…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n …
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a, b, and c. H…
[题目链接]:http://codeforces.com/contest/785/problem/C [题意] 容量为n的谷仓,每一天都会有m个谷子入仓(满了就视为m);第i天 会有i只鸟叼走i个谷子; 问哪一天谷仓最早变成空的了; [题解] 当n<=m的时候,答案就为n; 当n>m的时候; 从第m+1天起谷仓的入库量比不上鸟的食量了; 会开始减少; 其中第m+1天减少m+1; 此后第m+2-依次减少2,3,4- 即首项为2公差为1的等差数列; 先让n减去m+1 然后让这个数列的和大于等于剩下…