Topk algorithm_topn algorithm

Hello everyone, meet again, I am your friend Quanzhanjun.topK algorithmIdea 1: Quick Selection Algorithm The fast selection algorithm can be used. With the help of quick sorting, let mid be the intermediate result of each division. After each division, if mid==k, it means that the sequence is just right, and the k th position and the position ...

Posted by madhu on Wed, 21 Sep 2022 21:47:35 +0300

CF Round 812 F. Lost Array

F. Lost Array I spent many hours fooling around yesterday, reading the wrong questions and reading the wrong code. Finally, I got out of the mess. I wrote a blog to record the mentality of nearly breaking the computer yesterday Observe the mysterious code of others and find the following mysterious properties For ordered column subset XOR, ...

Posted by Sillysoft on Thu, 15 Sep 2022 21:16:40 +0300

Derivation of C++ decltype type

decltype specifier (C++11) C++11 introduces a decltype specifier, which can obtain the type of an object or expression. It is also easy to use: #include <iostream> int main() { int x1 = 0; decltype(x1) x2 = 0; // x2 is derived as int type (type of variable x1) std::cout << typeid(x2).name() << s ...

Posted by bimbo on Wed, 07 Sep 2022 22:08:45 +0300

System Programming (I/O)

How Ubunt u implements the cp function ps: copy the content of one file to another file, test: text, image, video #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> int main(int argc, char*argv[]) { if(argc<3) { printf("Missin ...

Posted by dsp77 on Sun, 04 Sep 2022 08:27:48 +0300

Detailed notes on C + + operators

C + + operators 1, Arithmetic operator Unary operators (monocular) have the highest priority, followed by multiplication, division and remainder, and finally addition and subtraction. And it has left associativity, that is, when the priorities are the same, it is calculated from left to right. Monocular: + or - (unary positive / negativ ...

Posted by q1234ask on Fri, 02 Sep 2022 21:39:06 +0300

Notes on interfaces, polymorphism, inner classes, and more!

1. Static The static keyword can modify member variables and member methods basic concept: static member belongs to class It can be accessed through the class name, and is generally modified with public classname.propertyname; classname.methodname(); can also be accessed by object name (not recommended) Memory explanation: Sta ...

Posted by ess14 on Wed, 31 Aug 2022 03:28:19 +0300

Detailed explanation and implementation of c + + callback function (lambda)

A callback function is a function that is passed as a parameter. In C language, callback function can only be implemented by function pointer. In C + + language, you can also use imitative function or anonymous function. The use of callback function can greatly improve the efficiency of programming, which makes it widely used in modern programm ...

Posted by darkhappy on Mon, 22 Aug 2022 02:50:43 +0300

Item 10: Prefer scoped enums to unscoped enums

There is a basic principle that declaring a name in curly brackets restricts the visibility of the name to the scope of the curly brackets. However, enumerations declared in the C++98 style enum do not follow this principle. The visibility of these names extends to the scope containing the enumeration, meaning that the same name cannot be conta ...

Posted by Xil3 on Fri, 19 Aug 2022 03:29:34 +0300

2022 Hangzhou Electric Power Multi-School 9 (Summary + Supplement)

summary Today, this multi-school should be the best one to hit this summer vacation (although the ranking is not very high). My starting teammate found that the tree dp was signed in for question 1009. I thought about guessing an even-numbered side. I stared at my teammate and wrote A for ten minutes. Then we went to see 1003 again. After my t ...

Posted by thomasgrant on Thu, 18 Aug 2022 22:30:52 +0300

Programming problems related to C++ Dijkstra algorithm

#include<iostream> using namespace std; #define N 10000 #define Linit 11 void Dijstra(int edges[][Linit], int origin, int* dist, int* path); int main() { char str[200] = {'1','-','4',',','1','-','6',',','2','-','4',',','2','-','6',',','3','-','5',',','3','-','6',',','4','-','5',',','5','-','6'}; int origin = 1; int target = 3; in ...

Posted by dirkbonenkamp on Sat, 02 Jul 2022 21:45:03 +0300