There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill…
维护一个单调下降的队列. 对于每一个人,只需要找到在他前面且离他最近的可以杀掉他的人即可. #include <cstdio> #include <vector> #include <algorithm> #include <cstring> using namespace std; #define N 100005 vector<int> v; int f[N], n, t, cnt; int main() { scanf("%d&q…
Psychos in a Line CodeForces - 319B There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the…
B. Psychos in a Line Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/319/B Description There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who h…
D. Psychos in a Line time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho…
Codeforce 319 B. Psychos in a Line 解析(思維.單調棧) 今天我們來看看CF319B 題目連結 題目 給一個數列,如果相鄰兩數,左邊大於右邊,那麼就可以殺死右邊的數字(被殺死的數字在當前一輪也可以殺右邊的數字) 求幾輪以後就沒有數字會自相殘殺了? 前言 第一眼看到就感覺會和單調棧有關,但是實在經驗不足,最後思緒被拉跑到找遞增和遞減數列了... 想法 我們都知道,單調棧最一開始就是拿來找一個元素往左或往右的,第一個比元素本身大或小的元素. 但這題還需要我們利用單調…
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/problem/A Description You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon…
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segmen…
C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws…
B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second - number B, etc. till c…