随笔分类 - pat
摘要:#include <bits/stdc++.h> #define LOCAL using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { r
阅读全文
摘要:最长连续回文子串,正反匹配最长公共连续子串 #include <bits/stdc++.h> #define LOCAL using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, co
阅读全文
摘要:坑:路径后面车站多出来的车不能弥补前面的空缺 #include <bits/stdc++.h> #define LOCAL using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, c
阅读全文
摘要:码农题 #include <bits/stdc++.h> #define LOCAL using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p)
阅读全文
摘要:#include <bits/stdc++.h> #define LOCAL using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { r
阅读全文
摘要:#include<iostream> #include<cstring> using namespace std; const int N = 20; struct node{ int l, r, p; }tr[N]; int n; int q[N], tt = -1, hh; void trev(
阅读全文
摘要:**题意:**给定一个序列A,给定一个序列B,在A中找到满足序列B的最长不下降子序列 **思路:**维护一个B的顺序表,以O(1)得到颜色之间的大小关系,LIS模板 #include<iostream> #include<vector> using namespace std; const int
阅读全文
摘要:#include<iostream> #include<string> using namespace std; const int N = 100010; struct student{ string id, name; int grade; bool operator!=(const stude
阅读全文
摘要:**题意:**给定起点和终点,给定无向图和每一条边的长度和花费,求出从起点到终点的最短距离,如果路径不唯一输出花费最少的那一条路径,并输出最短距离和花费。 **思路:**dijkstra模板题,在发现两个路径长度相同时,如果一条路的花费更少则需要更新花费和路径,图用邻接矩阵存,邻接表复杂度会高一些
阅读全文
摘要:传送门 **题意:**给你一堆车的进出记录共N个(其中包含无效记录),再给K个询问,每一次给一个时间(时间是升序给出),输出此时有多少辆车在学校里,然后最后输出一下停车时间最长的车和它的时间,如果有多个,那么按字典序输出车牌号即可。 坑点: 一辆车可能会有多条进出记录,它的停车时间应该是合法等待时间
阅读全文
摘要:开始觉得是个什么两次遍历法,后来发现是RMQ问题,可以选择线段树,树状数组,ST表三种 再看数据范围:\(N <= 10^5\) 线段树/树状数组:\(O(nlogn)\) ST表:\(O(n)\) #include<iostream> #include<cmath> #include<vector
阅读全文
摘要:看见顶点涂色,还以为要dfs啥的,没想到就是简单模拟,散列表是手动模拟的没用unordered_map #include<iostream> #include<cstring> using namespace std; const int N = 10010, M = 20003; struct{
阅读全文
摘要:纯模拟,没有注意性质,插入排序的性质:排过序的部分A和为排过序的部分B,A升序,B和原序列一样。 所以可以先简单判断是不是插入排序,然后再求一个下一步就可以了 #include<iostream> using namespace std; const int N = 110; int a[N], b
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; const int N = 1010; int heap[N]; int n, flag; int isMax, isMin; vector<int> ans; void dfs(int
阅读全文
摘要:之前写的floyd被卡了????? 心态炸裂之dijkstra #include<iostream> #include<cstring> using namespace std; const int N = 510; int g[N][N], cnt[N], nums[N], dist[N], w[
阅读全文
摘要:#include<iostream> #include<cstdio> using namespace std; const int N = 200010; int cnt; int n, m; long a[N], b[N]; int main(){ scanf("%d", &n); for(in
阅读全文
摘要:高精加 #include<iostream> #include<vector> #include<algorithm> using namespace std; int check(vector<int> &a){ int l = 0, r = a.size() - 1; while(l < r){
阅读全文
摘要:Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135
阅读全文
摘要:A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years
阅读全文
摘要:A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the
阅读全文