From collections Import Dequedef search (lines, pattern, history=5): Previous_lines = deque (maxlen=history) For line in lines: If pattern in line: Yield Line,previous_lines Previous_lines.append (line)if __name__ = = '
topic 1117
topic information
run result
line
discussion area
Egg Queue time limit: +Ms | Memory Limit:65535KB Difficulty:1
Describe
A queue is formed by placing two chopsticks parallel together.
1
Vector
Vector is equivalent to an arrayAllocate a continuous memory space in the memory for storage. Storage with no vector size specified is supported. During internal implementation of STL, a very large memory space is allocated for storage,
Transfer from http://blog.csdn.net/xiaolajiao8787/article/details/5882609
Type
Vector
Deque
List
Memory management
Poor
Good
Perfect
accessing data using the [] and at ()
1VectorThe vector corresponds to an arrayAllocates a contiguous memory space in memory for storage. Supports storage that does not specify a vector size. STL internal implementation, first allocate a very large memory space to store, that is, the
10-20-30
A simple solitaire card game called 10-20-30 uses a standard deck of the playing cards in which suit is irrelevant. The value of a face card (King, Queen, Jack) is 10. The value of an aces is one. The value of each of
Vector
Elements stored continuously
Vector C;
C. Back () returns the last data and does not check whether the data exists.
C. Clear () removes all data from the container.
C. Empty () determines whether the container is empty.
C. Front () returns
Vector is a continuous memory block, while deque is multiple consecutive memory blocks. list is the storage of all data elements separately. It can be that any two elements are not consecutive. The query performance of vector is the best, and it is
1. Basic operations of Vector
(1) add, delete, and obtain dynamic array elements
The Code is as follows:
# Include # include using namespace STD; // add and delete array elements and obtain int main (void) {vector V1; v1.push _ back (1); v1.push _
Maps are associative, andvectors,lists,anddeque are sequential in type. Map: Underlying mechanism rb-tree(red-black tree), automatic ordering of elements, key-value pairs. Vector: operates in a similar way to array, with dynamic space growth. is a
1VectorThe vector corresponds to an arrayAllocates a contiguous memory space in memory for storage. Supports storage that does not specify a vector size. STL internal implementation, first allocate a very large memory space to store, that is, the
SGI-- Silicon Graphics [Computer System] Inc. Silicon graph [Computer System] Company.
STL-- Standard Template Library: Standard Template Library.
Container Concept
The STL container is to implement the most commonly used data structures.
A
Call header file: #include
using namespace Std;
Detailed usage (part):
Deque K; ------defines a deque variable (which was initialized at the time of definition) such as: Deque K;
K.empty ()------See if the example is empty, return 1, not return 0
K.
KpiTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 901 Accepted Submission (s): 398Problem description After you work, KPIs are all you have. I have developed a service that has gained a lot of
1 vectorVector is equivalent to an arrayAllocate a continuous memory space in the memory for storage. Storage with no vector size specified is supported. During internal implementation of STL, a very large memory space is allocated for storage, that
Ideas for reference from: http://blog.csdn.net/doris1104/article/details/51126910 thanksFind out the pattern of the last ball adjacent to the front ball (to satisfy the left greater than the right) and 2^ two ball spacing related-----> The closer
Expected = Total number of decrements in all casesThe number of decrements between the end of I and the i-1 will be recursive.Part of it is after the i-1, and part of it is a new generation after the first one has been put out.Note minus the extra
Bidirectional queueTime Limit: 1000 MS Memory limit: 65536 KDescriptionThink about two-way linked list ...... The definition of a two-way queue is similar. That is to say, the end of a queue is also the first. Both ends can be used to join the queue.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.