Time of Update: 2018-12-03
難得寫一道線段樹,先上代碼.....#include<cstdio>#include<cstring>#include<iostream>using namespace std;#define MAXN 50002struct node{ int l, mid, r; char ch; int v; char ll[2], rr[2]; int num; } a[MAXN*4];int n, m;void pushup(int
Time of Update: 2018-12-03
int a[S], b[S];void getExtendNext(char *str){ int id = 0, mx = 0; a[0] = n, a[1] = 0; for (int i = 1; i < n; i++) { if (mx > i + a[i - id]) { a[i] = a[i - id]; continue; } a[i] =
Time of Update: 2018-12-03
STL源碼學習----lower_bound和upper_bound演算法 STL中的每個演算法都非常精妙,接下來的幾天我想集中學習一下STL中的演算法。 ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)演算法返回一個非遞減序列[first, last)中的第一個大於等於值val的位置。 ForwardIter upper_bound(ForwardIter first,
Time of Update: 2018-12-03
通過乘法把最低位搞到最高位。#include <iostream>#include <cmath>#include <string>using namespace std;//#define TESTint main() {#ifdef TESTfreopen("input.txt", "r", stdin);#endifint base, n, m;while(cin >> base >> n >> m) {if(m ==
Time of Update: 2018-12-03
如果一個系統由n個變數和m個約束條件組成,其中每個約束條件形如xj-xi<=bk(i,j∈[1,n],k∈[1,m]),則稱其為差分約束系統(system of difference
Time of Update: 2018-12-03
乍一看挺鬱悶的。。這麼長的題。後來好好看看題,好像不太難,好多題都是可以根據範例輸入輸出來判斷題的。。。這道也是。。 從輸入的序列右下角開始往上逆序輸出,即a[n][n].....a[0][n] a[n][n-1]...a[0][n-1]一直這樣。。。感覺成就感的是沒有PE,一次AC,嘻嘻~ #include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ int n,len,
Time of Update: 2018-12-03
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=114&problem=39&mosmsg=Submission+received+with+ID+8687266 題目大意: 輸入k個n維的東西(當n=2的時候看成框,n=3時看成方體,之後是超立方..),求 最大 的長度
Time of Update: 2018-12-03
Q10034: Freckles給你一些點的座標,把這些點用墨水畫直線連起來,使得所有的點最後都連在一起。你的任務是寫一個程式找出墨水畫出的長度最小是多少?Input輸入的第一列有一個整數,代表以下有幾組測試資料。每組測試資料的第1列有一個整數n(0< n <= 100),代表點的個數。接下來有n列代表這n個點的座標,每列有2個實數。輸入的第一列與第一組測試資料間空一列,各測試資料間亦空一列。請參考Sample
Time of Update: 2018-12-03
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black
Time of Update: 2018-12-03
跳到分析 跳到代碼 題目大意: 給出一個無向圖(可以有環),要求從指定起點到指定終點的最短距離。 題目的輸入輸出很噁心,下面給出sample: Sample Input 1 1 3 // i=1,1-th行 ,指序號為 i 的點跟 哪些 大於i 的點相鄰, 第一個數X 指 後面有X個數。2 3 43 4 5 61 61 72 12 131 82 9 101 111 112 12 171 142 14 152 15 161 161 192
Time of Update: 2018-12-03
dijkstra~~~ 自己想得挺麻煩的,而且一直錯,看了某洋的,呃,明白了。。 我發現自己寫代碼都沒有好好想想,感覺就是套公式,公式套不了就不會了。笨蛋啊。。。 這個需要自己想的,dis裡面儲存的是 每個城市貨物到capital 的 最大 rate。這個想法很好啊。。。。 動動腦子吧。。 #include <stdio.h>#include <stdlib.h>#include <memory.h>#define N 102#define F 0.00000
Time of Update: 2018-12-03
本文會介紹幾種複雜度不同的演算法,並給出實現。 一、轉化為最長公用子序列(LCS)求解二、普通dp三、LIS的O(nlogn)演算法 問題描述:設L=<a1,a2,…,an>是n個不同的實數的序列,L的遞增子序列是這樣一個子序列Lin=<aK1,ak2,…,akm>,其中k1<k2<…<km且aK1<ak2<…<akm。求最大的m值。很明顯注意到子序列跟子串是有區別的。 一、轉化為最長公用子序列(LCS)求解 , O(n2)設序列X=&
Time of Update: 2018-12-03
HDU題目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4320 SWUN地址:http://218.194.91.48/acmhome/problemdetail.do?&method=showdetail&id=1429 SWUN裡的這題是從我從HDU搬過去的哈。。。 12年多校第三場,A題。 ===================================================================
Time of Update: 2018-12-03
不懂三分,發現個很不錯的,講三分的,轉一下。 http://hi.baidu.com/acmdearway/blog/item/8cb3370240ba3d9cd53f7c00.html 三分法——求解凸性函數的極值問題——czyuan原創 二分法作為分治中最常見的方法,適用於單調函數,逼近求解某點的值。但當函數是凸性函數時,二分法就無法適用,這時三分法就可以“大顯身手”~~ ,類似二分的定義Left和Right,mid = (Left + Right) /
Time of Update: 2018-12-03
題目地址 : http://poj.org/problem?id=1436 題目其實有點搓。 區間查詢與更新。 重點在於如何判斷。 題意讀了好幾天,沒讀懂。。。 還來還是查了別人的翻譯,才頓悟了。 水平可見的意思:兩垂線段之間,有其中一部分可以相連(即中間沒有其它線段)。 所以範例的三元組是:0~3 ,3~4,0~4 。 水平可見部分,分別是:3~3,2~3,3~4。 OK,題意理解後,非常好敲~~
Time of Update: 2018-12-03
Background In the ACM/ICPC Regional Contest, all the teams are ranked according to the most problems solved. For the purposes of awards, or in determining qualifier(s) for the World Finals, teams who solve the same number of problems are ranked by
Time of Update: 2018-12-03
Description:The 11th Zhejiang University Programming ContestStart Time:2011-04-03 13:30:00 (GMT+8) Length:4 Hours 解題報告連結如下(其他沒A出來的會慢慢補上): AAkasim Matrix0.00% (0/33)BBinary Land21.42% (18/84)CChinese Zodiac62.41% (382/612)DDuck Typing14.37%
Time of Update: 2018-12-03
Given a number sequence which has N element(s), please calculate the number of different collocation for three number Ai, Aj, Ak, which satisfy that Ai < Aj > Ak and i < j < k.InputThe first line is an integer N (N <= 50000). The
Time of Update: 2018-12-03
分析:前段時間做的,大概是先求逆序數,再根據這個O(m)推出可能的最大逆序數。類型:單點更新, 樹狀數組 / 線段樹代碼(樹狀數組):#include<cstdio>#include<cstring>using namespace std;#define MAXN 5002#define INF 1<<30#define LOWBIT(x) x&(-x)int c[MAXN];int a[MAXN];//原序int n;void insert(int
Time of Update: 2018-12-03
很繁瑣的一道題。 將網址的一些東西分開,真夠麻煩的。我想起來那個那個站長的網站分析某個網站的流量。把子網站的網址輸入後,分析的是總站的流量。哈~用的是這個原理嗎??嘻嘻。 練習使用了memset函數,用來初始化的好函數~~~~~用了好多。。。 我是把每個部分存到temp這個數組裡,然後輸出,其實可以直接輸出滴說。。。題目要求沒看清,導致代碼冗長。。。沒有看到所說的一些限制。。。基本是看了範例輸入輸出就開始做了。。。悲劇 嗯,容易PE。。。 #include