alds1专题

ALDS1_5_D 2018-2-24

#include<iostream>#include<cstdio>using namespace std;const int MAX = 500000;const int maxnum = 1000000010;// 两个局部数组int L[MAX / 2 + 2], R[MAX / 2 + 2];int A[MAX], n;long long cnt ;// 排序和合并void

ALDS1_6_C 2018-2-24

#include<iostream>#include<cstdio>using namespace std;const int MAX = 100000;const int maxnum = 1000000010;struct Card {char suit;int value;};Card L[MAX / 2 + 2], R[MAX / 2 + 2];// 排序和合并void mer

ALDS1_5_C 2018-2-23

#include<iostream>#include<cstdio>#include<cmath>using namespace std;const double PI = acos(-1.0);struct Point{double x,y;};void koch(int n, Point a, Point b) {// 递归结束if (n == 0)return;// 三等分点s,t

ALDS1_4_D 2018-2-22

#include<iostream>#include<cstdio>#include<cstring>using namespace std;typedef long long LL;LL A[100000 + 10];int n, k;//模拟装货过程bool check(LL P) {int cnt = k;for (int i = 0; i < n; ) {LL t = P;

ALDS1_5_D 逆序数 2018-2-11

using namespace std;const int MAX = 500000;const int maxnum = 1000000010;// 两个局部数组int L[MAX / 2 + 2], R[MAX / 2 + 2];int A[MAX], n;long long cnt ;// 排序和合并void merge(int left, int mid, int right)

ALDS1_6_A

计数排序 执行步骤  首先将C数组下的每个元素A[i]的值累加起来,C[A[i]]++然后从前往后累加C数组,C[i] = C[i] + C[i-1],这样的累加过程实际上将数值为i的最大位置保存了,之后从最大位置往前填充数据。由于存在多个相同元素的情况,所以在输出A元素Ai前,先修正计数用的C[Ai],C[Ai]=C[Ai]−1。修正过程实际上是往前移动,因为C数组累加过程已经保证存储数字

Aizu - ALDS1_7_A

Rooted Trees 问题 A graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or

Aizu - ALDS1_7_B

Binary Tree 题目 A binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree T and prints the following inf