AcWing 828. 模拟栈 #include <bits/stdc++.h> using namespace std; const int N=1e6+10; int stk[N],tt; void init(){ tt=0; } void add(int x){ stk[++tt]=x; } ...
AcWing 829. 模拟队列 #include <bits/stdc++.h> using namespace std; const int N=1e6+10; int q[N],hh,tt; void init(){ hh=0; tt=-1; } void add(int x){ q[++tt ...
AcWing 830. 单调栈 #include <bits/stdc++.h> using namespace std; const int N=1e6+10; int n; int stk[N],tt; int main(){ cin.tie(0); ios::sync_with_stdio(f ...
Given a string P consisting of only parentheses and asterisk characters (i.e. "(", ")" and ""), you are asked to replace all the asterisk characters i ...
分类:
其他好文 时间:
2020-07-29 12:38:40
阅读次数:
208
使用ios::sync_with_stdio(false)可以让cin读入的更快,它的原理是使本该同步的输入输出流分开,就是让c风格的输入输出流和c++的输入输出流分开。 举一个具体的例子,在正常c++中,当我们用cin输入整数,当我们在键盘上输入的时候,我们输入的东西进到了缓冲区,假设我们输入了 ...
分类:
移动开发 时间:
2020-07-28 22:41:21
阅读次数:
126
#include<iostream> #include<cstdio> using namespace std; float a, b, c, d; float l, r; float clac(float x){ return a * x * x * x + b * x * x + c * x + ...
分类:
其他好文 时间:
2020-07-28 22:15:33
阅读次数:
72
在认识yield的时候,网上很多文章都是说这个是个生成器,但是我并不知道这个是用来做什么的,所以概念很快就忘记了,后面读了几个文章以后感觉茅塞顿开。我就接介绍一下。 有一篇文章提到,可以把yield看成是生成器的return的一部分,首先一个return的作用是在程序中返回某个值,返回之后程序就不再 ...
分类:
编程语言 时间:
2020-07-28 14:38:10
阅读次数:
78
WA代码如下: 1 #include<bits/stdc++.h> 2 using namespace std; 3 map<string, string> mmp; 4 map<string, int> has; 5 int main() 6 { 7 int n, m; cin >> n >> m ...
分类:
其他好文 时间:
2020-07-28 14:31:36
阅读次数:
56
AcWing 799. 最长连续不重复子序列 #include <bits/stdc++.h> using namespace std; const int N=1e6+10; int a[N],s[N]; int main(){ int n; cin>>n; for(int i=0;i<n;i++ ...
AcWing 801. 二进制中1的个数 #include <bits/stdc++.h> using namespace std; int lowbit(int x){ return x&-x; } int main(){ int n; cin>>n; while(n--){ int x,res= ...