本文整理汇总了C++中vi类的典型用法代码示例。如果您正苦于以下问题:C++ vi类的具体用法?C++ vi怎么用?C++ vi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vi类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: HLD
HLD(vvi &childs, vi &p) : V(p.size()), T(0), p(p), childs(childs),
pr(V,-1), size(V,-1), heavy(V,-1), t_in(V,-1), t_out(V,-1) {
dfs(0); set_pr(0,0);
}
开发者ID:TimonKnigge,项目名称:Competitive-Programming,代码行数:4,代码来源:LCASQ.cpp
示例2: conv
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
开发者ID:hamko,项目名称:procon,代码行数:1,代码来源:c.cpp
示例3: SegmentTree
SegmentTree(vi &_A){
size = (int)_A.size();
A = _A;
tree.assign(size*4,0);
build(1,0,size-1);
}
开发者ID:faridtsl,项目名称:CompetitiveUtilities,代码行数:6,代码来源:SegementTree.cpp
示例4: print
// print function
// the number is stored in a vector with the 0th position being the least
// significant 'bits' -> go from last to first and concatenate to print
// the correct output
void print(const vi &v) {
for (vi::const_reverse_iterator rit = v.rbegin(); rit != v.rend(); ++rit) {
(rit != v.rbegin()) ? printf("%04d", *rit) : printf("%d", *rit);
}
printf("\n");
}
开发者ID:stephanseebacher,项目名称:codechef,代码行数:10,代码来源:FCTRL2.cpp
示例5: SegmentTree
SegmentTree(const vi &_A){
A = _A; n = (int) A.size();
st.assign(n * 4, 0);
lazy.assign(n * 4, -1);
build(1, 0, n - 1);
}
开发者ID:josejoaquimt,项目名称:Quest-es-Questions-URI,代码行数:6,代码来源:URI+2185+-+Brincando+com+Pomekons.cpp
示例6: contains
bool contains(int N){
vi::iterator it = lower_bound(marks.begin(), marks.end(), N);
if(*it == N)return true;
return false;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:5,代码来源:D.cpp
示例7: main
int main(){
FASTER;
cin >> n >> q;
vi W(3000000,0);
ft.assign(6000000,0);
for (int i = 0; i < n; ++i) {
int t;
cin >> t;
v.push_back(t);
W[t]++;
if(query(t,t) == 0){
update(t,1);
}
}
st1.assign(20000000,0);
st2.assign(20000000,0);
buildMax(1,0,v.size()-1);
buildMin(1,0,v.size()-1);
for (int i = 0; i < q; ++i) {
char c;
int x,y;
cin >> c >>x >> y;
if(c == 'Q'){
y--;
int maxi = queryMax(1,0,v.size()-1, x,y);
int mini = queryMin(1,0,v.size()-1, x,y);
printf("range (%d,%d) = %lld %lld\n",mini,maxi, v[mini], v[maxi]);
ll cnt = query(v[mini],v[maxi]);
cout << cnt << endl;
}else{
ll val = v[x];
if(W[val]){
printf("remove %lld\n", val);
W[val]--;
if(W[val] == 0 && query(val,val) == 1){
update(val,-1);
}
}
W[y]++;
if(query(y,y) == 0){
update(y,1);
}
updateMax(1,x,0,(int)v.size()-1,y);
updateMin(1,x,0,(int)v.size()-1,y);
}
}
return 0;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:62,代码来源:12345.cpp
示例8: make_set
inline void make_set(vi& set,int size) {
set.resize(size);
rep(i,size)set[i]=i;
}
开发者ID:karan007,项目名称:acmicpc-codes,代码行数:4,代码来源:223C.cpp
示例9: conv
using vi = vector<int>; using vvi = vector<vi>; vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
开发者ID:hamko,项目名称:procon,代码行数:1,代码来源:d.cpp
示例10: main
int main(){
scanf("%d %d %d %d",&n, &l, &x, &y);
for (int i = 0,t; i < n; ++i) {
scanf("%d", &t);
marks.push_back(t);
}
// sort(mea.begin(), mea.end());
bool containsX = false,containsY = false;
if(containsCut(x)){
containsX = true;
}
if(containsCut(y)){
containsY = true;
}
vi new_mark;
// Solve both
if(!containsX && !containsY){
for (int i = 0; i < n; ++i) {
int u = marks[i];
// printf("u + x + y = %d\n",u + x + y);
if(u + x + y <= l && contains(u + x + y)){
new_mark.push_back(u+x);
containsX = containsY = true;
break;
}
if(u - x - y >= 0 && contains(u - x - y)){
new_mark.push_back(u-x);
containsX = containsY = true;
break;
}
if(u + x <= l && contains(u + x - y)){
new_mark.push_back(u+x);
containsX = containsY = true;
break;
}
if(u + y <= l && contains(u + y - x)){
new_mark.push_back(u+y);
containsX = containsY = true;
break;
}
if(u - x >= 0 && contains(u - x + y)){
new_mark.push_back(u-x);
containsX = containsY = true;
break;
}
if(u - y >= l && contains(u - y + x)){
new_mark.push_back(u-y);
containsX = containsY = true;
break;
}
}
}
if(!containsX){
new_mark.push_back(x);
}
if(!containsY){
new_mark.push_back(y);
}
printf("%d", (int)new_mark.size());
for (int i = 0; i < new_mark.size(); ++i) {
if(i)printf(" ");
else printf("\n");
printf("%d",new_mark[i]);
}
printf("\n");
return 0;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:71,代码来源:D.cpp
示例11: st_create
void st_create(vi &st, const vi &a)
{
int size = (int)(2 * pow(2.0, floor((log((double)a.size()) / log(2.0) + 1))));
st.assign(size, 0);
st_build(st, a, 1, 0, (int)a.size() - 1);
}
开发者ID:GreenRecycleBin,项目名称:Competitive-Programming,代码行数:6,代码来源:segment_tree.cpp
示例12:
SegmentTree(const vector<int> &_A){
A = _A; n = (int)A.size();
st.assign(4 * n, 0);
build(1, 0, n-1);
}
开发者ID:orlandoaceto,项目名称:UVaOnlineJudge,代码行数:5,代码来源:12532.cpp
示例13:
UnionFind(int n){
rank.resize(n,0);
parent.resize(n);
size.resize(n,1);
for(int i=0;i<n;++i)parent[i]=i;
}
开发者ID:rkkautsar,项目名称:cp-solutions,代码行数:6,代码来源:10685.cpp
示例14: rep
rep(i,N){
int t; cin >> t;
dist.pb(t);
}
开发者ID:hadrori,项目名称:hadrori.github.io,代码行数:4,代码来源:3258.cpp
示例15: update
void update(int p, int val){
for(;p<ft.size();p += (p&(-p))){
ft[p] += val;
}
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:5,代码来源:12345.cpp
示例16: invf
void invf() {
int i = 0, j = f.size()-1;
for(; i<j; i++, j--) {
swap(f[i], f[j]);
}
}
开发者ID:rebecacalazans,项目名称:CP,代码行数:6,代码来源:d.cpp
示例17: update
void update(ll i){
for(;i<ft.size();i += (i &(-i))){
ft[i] += 1LL;
}
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:5,代码来源:H.cpp
示例18: main
int main(){
FASTER;
int n,m;
while(cin >> n >> m, n || m){
A.assign(n+1,0);
for (int i = 1; i <= n; ++i) {
cin >> A[i];
}
int s = 0;
MEM(C,0);
// pre-compute
for (int i = 1; i <= n; ++i) {
s = A[i];
for (int j = i+1; j <= n; ++j) {
C[i][j] = s * A[j] + C[i][j-1];
s += A[j];
}
}
if(m == 0){
cout << C[1][n] << endl;
continue;
}
MEM(dp,0);
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= m+1; ++j)
dp[i][j] = 1e9;
// Slow
// dp[0][0] = 0;
// for (int i = 1; i <= n; ++i) {
// for (int j = 1; j <= i; ++j) {
// for (int k = 1; k <= i; ++ k) {
// int tmp = dp[k-1][j-1] + C[k][i];
// dp[i][j] = min(dp[i][j], tmp);
// }
// }
// }
// cout << dp[n][m+1] << endl;
// Fast
dp[n+1][0] = 0;
for (int i = n; i >= 1; --i) {
for (int j = 1; j <= n; ++j) {
for (int k = i; k <= n; ++k) {
int tmp = dp[k+1][j-1] + C[i][k];
// optimization
if(C[i][k] > dp[i][j] )break;
dp[i][j] = min(dp[i][j], tmp);
}
}
}
cout << dp[1][m+1] << endl;
}
return 0;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:65,代码来源:SuluChallengestheBorg.cpp
注:本文中的vi类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论