February 24- second class machine test record
to sum up
- The optimization may consider using simulation to reduce the time complexity STL
- For the time complexity is reduced
- In the method, the shift n logn reduced to such ideas
- But also consider the various details, such as
- Input and output, instead of using printf cout
- mp.count () but is redundant judgment
- Use unordered_map
- For the topic sometimes thinking can be modeled from another point of view, such as that network problems, perform bfs bfs more streamlined than the pour point of view from the enumeration
- Simulation optimization, the base for the conversion of large volumes of data that prompted the question, told a need to think from a new perspective
Topic No.
simple
- PIPIOJ 1332 reverse substring between parentheses (stack + string)
- 1334 of PIPIOJ PIPI count (Map)
- PIPIOJ 1065 Statistics balloon (map)
- 1070 is PIPIOJ PIPI array (map + vector)
- PIPIOJ 1037 ranking (sort)
- PIPIOJ 1150 integer sorted (sort, string)
problem
- PIPIOJ 1325 social network (queue)
- PIPIOJ 1114 hex conversion (map + string)
- PIPIOJ 1173 PIPI collection (unordered_map)
- PIPIOJ 1330 PIPI Lego (set)
Ideas and Tips
1332
- Save a char * string, the reception line requires the gets ();
- Stl used in reverse (a, b) to [a, b) is inverted directly
char str[100]; gets(str); reverse(str + a, str + b);
1325
The idea is the beginning of bfs down, reverse push back, but the code is too complicated, and the answer is the reference point for each enumeration poisoning, and the simulation results were bfs contrast, bfs time complexity is O (points + the number of edges) , multiplied by the number of infected will not timeout
Because the points more than the edge, can be declared using the vector adjacent table, noting that undirected graph you want to store twice
bfs vis array requires access point to avoid duplication, and using memset vis initializing the array can be used multiple times
1037
- C ++ need is greater than the string symbols overloaded, if required using the char compared with strcmp, or just a pointer to compare
1114
Prior to Hang a small electrical problem did amount of data, you can format the input and output through simplification, but this problem large amount of data can only be considered for simulation, if direct cross-border decimal simulation still, so consider direct binary emulation how to use the map to simplify the simulation process
scanf("%x", &a); printf("%o", a);
1173
A preprocessing on the idea, so that the time complexity from O (n ^ 4) down to O (n ^ 2)
TLE several easy points
Use unordered_map (map reuse requires Clear)
Outside the main initialization function, defined to avoid duplication
After mp.count (key) is determined in addition be a problem, because of the added directly mp [key]
1330
- Classic using the set of topics, because of the need to return the components to delete and add sort, so the use of set (its own internal sorting) operation, each operation is o (logn)