mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-09-05 17:50:36 +00:00
docs: 更新README并清理测试代码
更新README添加超时优化方法,同时清理test.cpp中未使用的代码
This commit is contained in:
parent
64a6dc8651
commit
17a58ec2aa
@ -13,4 +13,9 @@
|
|||||||
###
|
###
|
||||||
1. 编辑距离 i-1,j i,j-1
|
1. 编辑距离 i-1,j i,j-1
|
||||||
2. 合并石子 1~k,k+1~i
|
2. 合并石子 1~k,k+1~i
|
||||||
3. 网捉蛇 1~k用j-1, k+1~i用1
|
3. 网捉蛇 1~k用j-1, k+1~i用1
|
||||||
|
|
||||||
|
## 超时优化的三种方法
|
||||||
|
1. 预处理(排序最常用)
|
||||||
|
2. 二分
|
||||||
|
3. 数学方法
|
18
src/test.cpp
18
src/test.cpp
@ -1,19 +1,3 @@
|
|||||||
#include <cmath>
|
|
||||||
#include <iostream>
|
|
||||||
#include <set>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
int main(){
|
int main(){
|
||||||
int n;
|
|
||||||
std::cin>>n;
|
|
||||||
std::set<int> s;
|
|
||||||
std::cout<<n<<"\n";
|
|
||||||
for(int i=1;i<=n;i++){
|
|
||||||
int tmp;
|
|
||||||
std::cin>>tmp;
|
|
||||||
if(s.find(tmp)==s.end()){
|
|
||||||
throw std::runtime_error(std::to_string(tmp));
|
|
||||||
}
|
|
||||||
s.insert(tmp);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user