原创 CF208 E.Blood Cousins(樹上啓發式合併)

題目鏈接:CF208E Polycarpus got hold of a family relationship tree. The tree describes family relationships of n people,

原创 基於java實現的OPT算法

1966年,Belady提出最佳頁面替換算法(OPTimal replacement,OPT)。是操作系統存儲管理中的一種全局頁面替換策略 。 當要調入一頁而必須淘汰舊頁時,應該淘汰以後不再訪問的頁,或距最長時間後要訪問的頁面。它

原创 Atcoder abc128 D

Problem Statement Your friend gave you a dequeue D as a birthday present.D is a horizontal cylinder that contains a

原创 abc134 D - Preparing Boxes

題目鏈接:ABC 134D 題意:給你一個序列a,讓你構造一個序列b,序列裏面只有數字0和1,滿足以下條件: 對於位置i,將所有是i的倍數的下標裏的值相加,取餘2必須等於ai。 思路:直接從後往前模擬一遍就可以了,因爲後面的數會影

原创 K-th Number POJ - 2104 (主席樹+離散化)

You are working for Macrohard company in data structures department. After failing your previous task about key ins

原创 abc134 E

題目鏈接:abc134 E 題意:給你n個數,現在要將它們染色,兩個數字有一樣的顏色必需滿足以下條件,當i<j,Ai<Aj。 意思就是如果它們顏色要相同就必須要是一個上升子序列。 思路:直接模擬就可以了。假定一個集合,一個數加入集

原创 atcoder abc128c

題意:有n個開關和m個燈泡,每個燈泡關聯k個開關,當燈泡關聯的開關開着的數量取餘2等於p時,燈泡亮起,現在問你有多少種方式讓燈泡全亮。 思路:利用二進制,直接模擬所有狀態即可。 代碼: #include<bits/stdc++.h

原创 HDU - 3887 Counting Offspring(dfs序+主席樹)

Problem Description You are given a tree, it’s root is p, and the node is numbered from 1 to n. Now define f(i) as

原创 922 D. Robot Vacuum Cleaner

題目鏈接:922D D. Robot Vacuum Cleaner time limit per test1 second memory limit per test256 megabytes inputstandard inpu

原创 高斯消元模板

#include<bits/stdc++.h> #define ULL unsigned long long #define LL long long #define Max 100005 #define mem(a,b) mem

原创 CF600E Tree Requests(樹上啓發式合併模板題)

題目鏈接:CF600E You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let’s call c

原创 D. Tree Requests (樹上啓發式合併)

題目鏈接:CF570D Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex

原创 CodeForces - 208E Blood Cousins(樹上啓發式合併)

Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to

原创 CF620 E. New Year Tree(DFS序+狀態壓縮+線段樹)

題目鏈接:CF620E 題意: 給你一顆n個節點的樹,每個節點被染上了顏色,然後就是m次查詢。 查詢的方式有兩種 1,將以z爲根的子樹的結點全部更新爲顏色X 2,問以z爲根的子樹的結點的不同顏色數量。默認根爲1 Input 第一行

原创 Scu4438 棧+哈希

題目描述 現在給定一個你很討厭的字符串 A 和另外一個字符串 B,請刪除在 B 中出現的所有 A。 請注意:有可能在刪除一個 A 後導致新的 A 出現,此時請繼續刪除,直到沒有 A。 輸入格式 輸入爲多組數據,請處理到 EOF。