本文整理汇总了C++中vi::pb方法的典型用法代码示例。如果您正苦于以下问题:C++ vi::pb方法的具体用法?C++ vi::pb怎么用?C++ vi::pb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vi
的用法示例。
在下文中一共展示了vi::pb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coin_change
bool coin_change(int k, int left_pane, int right_pane, int taken, bool flag, vi panes)
{
int i;
if(taken==m)
{
outs=panes;
return 1;
}
for(i=1; i<=10; i++)
{
if(i==k) continue;
if(!flag && coins[i] && left_pane+i>right_pane)
{
panes.pb(i);
if(coin_change(i,left_pane+i,right_pane,taken+1,!flag,panes)) return 1;
panes.pop_back();
}
if(flag && coins[i] && right_pane+i>left_pane)
{
panes.pb(i);
if(coin_change(i,left_pane,right_pane+i,taken+1,!flag,panes)) return 1;
panes.pop_back();
}
}
return ret;
}
示例2: main
int main () {
#ifndef ONLINE_JUDGE
freopen(INP, "r", stdin); freopen(OUT, "w", stdout);
#endif
scanf("%d", &n);
order.clear();
arr1.assign(n+1,0);
a1.clear();
FOR(i,1,n) scanf("%d", &a), a1.pb(a);
REP(i,n) arr1[a1[i]-1] = i+1;
REP(i,n) order[arr1[i]] = i;
while(scanf("%d", &a) != EOF){
arr.assign(n+1,0);
a2.clear();
a2.pb(a);
ans.resize(0);
len = 0;
FOR(i,1,n-1) scanf("%d", &a), a2.pb(a);
REP(i,n) arr[a2[i]-1] = i+1;
REP(i,n) updateLis(arr[i]);
cout << len << endl;
}
return 0;
}
示例3: find
int TheArray::find (int _n, int _d, int _first, int _last)
{
arr.clear();
d = abs(_d);
n = _n;
first = _first;
last = _last;
if(first > last)
swap(first, last);
arr.pb(first);
while(arr.size() < n){
lft = n - arr.size();
if(arr.back() + 0 - d*(lft-1) <= last)
arr.pb(arr.back() + find1(0, d));
else
arr.pb(max(arr.back()-d, last));
}
/*
tr(it, arr)
write(*it);
cout << endl;
*/
return *max_element(all(arr));
}
示例4: GET
// elfekra kolha en el diff yeb2a minimum 3la ad ma2dar f ba7wel ene a generate every possible diff
// w homa 2 cases ema abd2a b 0 aw b 1 fagrab kolo w a5tar ela7san
// GET betgeb law habda2 b 0 EX :- 011010010 while ene ma7afz 3 eltarteb
// GET1 betgeb law habda2 b 1
int GET(){
int it1 = 1, it2 = 1 , i = 1;
int st = 0 ;
while(it1 <= n && it2 <=m){
while(A[it1]==st && it1<=n){
seq.pb(it1);
H[0][i++]=A[it1++];
}
while(B[it2]==st && it2<=m){
seq.pb(it2+n);
H[0][i++]=B[it2++];
}
st = 1 - st ;
}
while(it1<=n){ seq.pb(it1) ; H[0][i++]=A[it1++]; }
while(it2<=m){ seq.pb(it2+n) ; H[0][i++]=B[it2++]; }
int dif = 0;
forn(i , 2 , n+m+1)
if(H[0][i]!=H[0][i-1]){
dif++;
// saved me from many TLE
ans[0].pb(i-1);
}
last[0]=(H[0][n+m]==0 );
if(H[0][n+m] ){ dif++;ans[0].pb(n+m);}
return dif;
}
示例5: sieve
void sieve()
{
for(int i = 0 ; i <= maxN ; i++)
check[i] = true;
for(ll i = 2 ; i <= maxN ; i++)
{
if(check[i])
{
primes.pb(i);
for(ll j = i ; i*j <= maxN ; j++)
check[i*j] = false;
}
}
a.pb(2);
rep(i,sz(primes))
{
int k = primes[i];
bool ok = true;
while(k)
{
if(k%10 == 0 || (k%10)%2 == 0)
{
ok = false;
break;
}
k /= 10;
}
if(ok) a.pb(primes[i]);
}
示例6: main
int main(){
int t, n, i, c;
scanf("%d", &t);
kase=1;
while(t--){
scanf("%s", str);
n = strlen(str);
grps.clear();
type.clear();
for(i=0; i<n; ){
if(str[i]=='a'){
c=0;
while(i<n && str[i]=='a') c++, i++;
grps.pb(c);
type.pb(0);
}else{
c=0;
while(i<n && str[i]=='b') c++, i++;
grps.pb(c);
type.pb(1);
}
}
done = (1<<grps.size())-1;
printf("%d\n", recur(0));
kase++;
}
return 0;
}
示例7: convex_hull
void convex_hull(vector<Point> & a) {
if (a.size() == 1)
return;
sort(a.begin(), a.end(), &cmp);
Point p1 = a[0], p2 = a.back();
vector<Point> up, down;
up1.clear();
down1.clear();
up.push_back(p1); up1.pb(0);
down.push_back(p1); down1.pb(0);
for (size_t i = 1; i < a.size(); ++i) {
if (i == a.size() - 1 || ccw(p1, a[i], p2)) {
while (up.size() >= 2 && !ccw(up[up.size() - 2], up[up.size() - 1], a[i]))
up.pop_back(),up1.pop_back();
up.push_back(a[i]),up1.push_back(i);
}
if (i == a.size() - 1 || cw(p1, a[i], p2)) {
while (down.size() >= 2 && !cw(down[down.size() - 2], down[down.size() - 1], a[i]))
down.pop_back(),down1.pop_back();
down.push_back(a[i]),down1.push_back(i);
}
}
if (up[0].x == up.back().x && up[0].y == up.back().y)
up.erase(up.end() - 1),up1.erase(up1.end()-1);
a.clear();a1.clear();
for (size_t i = 0; i < up.size(); ++i)
a.push_back(up[i]),a1.push_back(up1[i]);
for (size_t i = down.size() - 2; i > 0; --i)
a.push_back(down[i]),a1.push_back(down1[i]);
}
示例8: GET2
int GET2(){
int it1 = 1, it2 = 1 , i = 1;
int st = 1 ;
while(it1 <= n && it2 <=m){
while(A[it1]==st && it1<=n){
seq1.pb(it1);
H[1][i++]=A[it1++];
}
while(B[it2]==st && it2<=m){
seq1.pb(it2+n);
H[1][i++]=B[it2++];
}
st = 1 - st ;
}
while(it1<=n){ seq1.pb(it1) ; H[1][i++]=A[it1++]; }
while(it2<=m){ seq1.pb(it2+n) ; H[1][i++]=B[it2++]; }
int dif = 0;
forn(i , 2 , n+m+1)
if(H[1][i]!=H[1][i-1]){
dif++;
ans[1].pb(i-1);
}
if(H[1][n+m] ){dif++;ans[1].pb(n+m);}
last[1]=(H[1][n+m]==0);
return dif;
}
示例9: sieve
// Prima pertama terdapat di primes[1] yah :D
void sieve(LL upperbound){
bs.set();
bs[0]=bs[1]=0;
primes.pb(0);
for(LL i=2; i<=upperbound+1; i++)if(bs[i]){
for(LL j=i*i; j<= upperbound+1; j+=i)bs[j] = 0;
primes.pb((int) i);
}
}
示例10: main
int main()
{
int temp,i;
char c;
cin>>n;
perm.pb(0);
done.pb(0);
for( i=1;i<=n;i++)
{
cin>>temp;
perm.pb(temp);
done.pb(0);
}
for( i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cin>>c;
if(c=='1')
mat[i][j]=1;
else
mat[i][j]=0;
}
}
for(i=1;i<n;i++)
{
if(done[i]==0)
{
bfs(i);
for(int j=0;j<help.size();j++)
sorted.pb(perm[help[j]]);
sort(help.begin(),help.end());
sort(sorted.begin(),sorted.end());
for(int j=0;j<help.size();j++)
{
perm[help[j]]=sorted[j];
}
help.clear();
sorted.clear();
}
}
for(i=1;i<n;i++)
cout<<perm[i]<<" ";
cout<<perm[i];
return 0;
}
示例11: extract
void extract()
{
for(i,0,sz){
if(isv(word[i])) {
vogais.pb(i);
onde[i] = vogais.size()-1;
}else{
consoantes.pb(i);
onde[i] = consoantes.size()-1;
}
}
}
示例12: solve
void solve() {
arr.clear();
p.clear();
/*
cin >> K >> N;
arr = vi(K);
forn(i, K)
cin >> arr[i];
*/
cin >> N >> K;
int64 b, c, r;
arr = vi(K);
cin >> arr[0] >> b >> c >> r;
forab(i, 1, K-1)
arr[i] = (arr[i-1]*b + c) % r;
forn(i, K)
write(arr[i]);
cout << endl;
sort(all(arr));
uni.pb(arr.front());
p.pb(mp(arr[0], arr[0]));
forn(i, K) {
if(arr[i] != uni.back())
uni.pb(arr[i]);
if(arr[i] == p.back().second)
;
else if(arr[i] == p.back().second+1)
p.back().second++;
else
p.pb(mp(arr[i], arr[i]));
}
forn(i, K)
write(arr[i]);
cout << endl;
forn(i, uni.size())
write(uni[i]);
cout << endl;
tr(it, p)
Pf("(%d, %d) ", it->first, it->second);
cout << endl;
int M = N;
forab(i, K, N) {
N = i;
Pf("arr[%d] = %d\n", N, binarySearch());
}
示例13: sieve
void sieve(int64 n){
int i, j;
bs.set();
bs[0] = bs[1] = 0;
primes.pb(1);
for(i=2; i<=n; i++){
if(bs[i]){
primes.pb(i);
if(i*1ll*i<=n)
for(j=i*i; j<=n; j+=i){bs[j] = 0;}
}
}
}
示例14: primeFill
void primeFill(int upBound){
vector <bool> row(upBound,1);
int del; //del += 2
for( del= 2; del*del <= upBound; ++del){
if(row[del]){
prime.pb(del);
for(int i = del*del; i <= upBound; i+=del)
row[i] = false;
}
}
for(;del < upBound; ++del)
if(row[del])
prime.pb(del);
}
示例15: main
int main(){
pre();
cin >> u >> v;
loop(i,len(v)){
if(v[i] == '0') zero.pb(i);
else one.pb(i);
}
ll ans = 0;
loop(i,len(u)){
vi *V;
if(u[i] == '0') V = & one;
else V = & zero;
ans += upper_bound(V->begin(),V->end(),len(v) - len(u) + i) - lower_bound(V->begin(),V->end(),i);
}