本文整理汇总了C++中vi::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vi::pop_back方法的具体用法?C++ vi::pop_back怎么用?C++ vi::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vi
的用法示例。
在下文中一共展示了vi::pop_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call1
int call1(int in,int one,int two)
{
if(in>=n)
{
int len=v.size()-x-x;
int flg=0;
for(int i=0;i<len;i++)
{
if(v[i]+v[i+x]+v[i+x+x]!=6)
{
debug(v[i],v[i+x],v[i+x+x])
flg=1;
break;
}
}
if(flg) return 1;
return 0;
}
if(mpp[MP(one,two)]!=0) return mpp[MP(one,two)];
v.PB(1);
int s1=call(one+1,two);
v.pop_back();
v.PB(2);
int s2=call(one,two+1);
v.pop_back();
v.PB(3);
int s3=call(one,two);
v.pop_back();
//if(val==-1) return (s1%MOD+s2%MOD+s3%MOD)%MOD;
return mpp[MP(one,two)]=(s1%MOD+s2%MOD+s3%MOD)%MOD;
}
示例2: call
int call(int in,int val)
{
if(in>=n)
{
int len=v.size()-x-x;
int flg=0;
for(int i=0;i<len;i++)
{
if(v[i]+v[i+x]+v[i+x+x]!=6)
{
//debug(v[i],v[i+x],v[i+x+x])
flg=1;
break;
}
}
if(flg) return 1;
return 0;
}
//if(val!=-1 && dp[val][in]!=-1) return dp[val][in];
v.PB(1);
int s1=call(in+1,0);
v.pop_back();
v.PB(2);
int s2=call(in+1,1);
v.pop_back();
v.PB(3);
int s3=call(in+1,2);
v.pop_back();
if(val==-1) return (s1%MOD+s2%MOD+s3%MOD)%MOD;
return dp[val][in]=(s1%MOD+s2%MOD+s3%MOD)%MOD;
}
示例3: compute_hull
void compute_hull() {
int pivot = 0, n = p.size();
vector<int> ps(n + 1, 0);
for (int i = 1; i < n; ++i) {
ps[i] = i;
if (comp_lexo(p[i], p[pivot])) pivot = i;
}
ps[0] = ps[n] = pivot; ps[pivot] = 0;
sort(ps.begin()+1, ps.end()-1, [this, &pivot](int l, int r) {
return comp_angl(p[l], p[r], p[pivot]); });
h.push_back(ps[0]);
size_t i = 1; ll d;
while (i < ps.size()) {
if (p[ps[i]] == p[h.back()]) { i++; continue; }
if (h.size() < 2 || ((d = det(p[h.end()[-2]],
p[h.back()], p[ps[i]])) > 0)) { // >= for col.
h.push_back(ps[i]);
i++; continue;
}
if (p[h.end()[-2]] == p[ps[i]]) { i++; continue; }
h.pop_back();
if (d == 0) h.push_back(ps[i]);
}
if (h.size() > 1 && h.back() == pivot) h.pop_back();
}
示例4: 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;
}
示例5: print
void print(int in, int make)
{
//debug(in,make,pri[in][make])
if(in>=n)
{
//debug("vi",v.size(),make)
if(make==0)
{
tc++;
call(0,0);
}
return;
}
int kk = pri[in][make];
if(kk==3)
{
v.PB(a[in]);
print(in+1,make-a[in]);
v.pop_back();
print(in+1, make);
}
else if(kk==1)
{
print(in+1, make);
}
else
{
v.PB(a[in]);
print(in+1, make-a[in]);
v.pop_back();
}
}
示例6: 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]);
}
示例7: cycleCheck
void cycleCheck(int u, int par) {
num[u] = EXPLORED;
path.push_back(u);
for (int i = 0; i < g[u].size(); i++) {
int v = g[u][i];
if (num[v] == UNVISITED) {
cycleCheck(v, u);
path.pop_back();
}
else if (num[v] == EXPLORED && v != par) {
vi cycle;
int i = path.size() - 1;
while (true) {
int n = path[i--];
cycle.push_back(n);
if (n == v) break;
}
vi temp = cycle;
sort(temp.begin(), temp.end());
if (dicc.count(temp) == 0) {
dicc[temp] = C++;
cycles.push_back(cycle);
}
path.pop_back();
}
}
num[u] = VISITED;
}
示例8: tarjanSCC
void tarjanSCC(int u)
{
dfs_low[u] = dfs_num[u] = dfsNumberCounter++;
S.push_back(u);
visited[u] = 1;
for (int j = 0; j < (int)AdjList[u].size(); j++)
{
int v = AdjList[u][j];
if (dfs_num[v] == UNVISITED)
tarjanSCC(v);
if (visited[v])
dfs_low[u] = min(dfs_low[u], dfs_low[v]);
}
if (dfs_low[u] == dfs_num[u])
{
int tam = 0;
while (1)
{
++tam;
int v = S.back(); S.pop_back(); visited[v] = 0;
if (u == v) break;
}
if (tam >= 2) ++numSCC;
}
}
示例9: scc
void scc(int u, int p = -1){
num[u] = lo[u] = cnt++;
vis[u] = 1;
cu.push_back(u);
for(auto v : G[u]){
if(num[v] == -1)
scc(v,u);
if(vis[v])
lo[u] = min(lo[u], lo[v]);
}
if(lo[u]==num[u]){
cc.push_back(vi());
int i = cc.size() - 1;
while(1){
int v = cu.back();
vis[v] = false;
cc[i].push_back(v);
cu.pop_back();
if(u == v)break;
}
}
}
示例10: take
void take() {
int p = pos.back(); pos.pop_back();
for (int pi : pos) {
int d = abs(pi-p);
cnt[d]++;
}
}
示例11: main
int main(){
ios_base::sync_with_stdio(false);
string linha;
//~ while(getline(cin,linha)){
getline(cin, linha);
//~ cout << linha << endl;
memset(st, 0, sizeof st);
cin >> m;
ans.assign(m, 0);
beg.assign(m, 0);
qs.assign(linha.size(), vi());
int a, b;
for(int i = 0; i < m; i++){
cin >> a >> b;
beg[i] = a-1;
qs[b-1].push_back(i);
}
op.clear();
int q;
for(int i = 0; i < (int)linha.size(); i++){
if(linha[i] == ')'){
if(op.size() > 0){
update(1,0,(int)linha.size()-1, op.back());
op.pop_back();
}
}
for(int j = 0; j < (int)qs[i].size(); j++){
q = qs[i][j];
ans[q] = query(1, 0, (int)linha.size()-1, beg[q], i);
}
if(linha[i] == '(') op.push_back(i);
}
示例12: tarjanSCC
void tarjanSCC(int u) {
dfs_low[u] = dfs_num[u] = dfsNumberCounter++; // dfs_low[u] <= dfs_num[u]
S.push_back(u); // stores u in a vector based on order of visitation
visited[u] = 1;
for (int j = 0; j < (int)AdjList[u].size(); j++) {
ii v = AdjList[u][j];
if (dfs_num[v.first] == DFS_WHITE)
tarjanSCC(v.first);
if (visited[v.first]) // condition for update
dfs_low[u] = min(dfs_low[u], dfs_low[v.first]);
}
if (dfs_low[u] == dfs_num[u]) { // if this is a root (start) of an SCC
int total = 0;
// printf("SCC %d:", ++numSCC); // this part is done after recursion
while (1) {
total++;
int v = S.back(); S.pop_back(); visited[v] = 0;
// printf(" %d", v);
if (u == v){
if(total == 1 && AdjList[u][0].first != u){
valid = false;
}
break;
}
}
// printf(" TOTAL: %d \n", total);
clyces.push_back(total % 2 == 0 ? total/2 : total);
}
}
示例13: tarjansSCC
/**
* a graph is said to be strongly connected if every vertex is reachable from every other vertex.
*/
void tarjansSCC(int u) {
dfs_num[u] = dfs_lo[u] = dfsNumberCounter++;
S.push_back(u);
visited[u] = true;
for(int i = 0 ; i < g[u].size() ; i++) {
int v = g[u][i];
if(dfs_num[v] == UNVISITED)
tarjansSCC(v);
if(visited[v])
dfs_lo[u] = min(dfs_lo[u], dfs_lo[v]);
}
if(dfs_num[u] == dfs_lo[u]) {
printf("SSC %d:", ++numSCC);
while(1) {
int v = S.back();
S.pop_back();
visited[v] = false;
printf(" %d", v);
if(v == u)break;
}
printf("\n");
}
}
示例14: backtracking
void backtracking(vi s,vi steps, int d){
if(vist.find(s) != vist.end() || d > limit){
// printf("return d = %d limit = %d\n", d, limit);
return;
}
if(done || isDone(s)){
if(!done){
// printf("found!\n");
ans = steps;
}
done = true;
return;
}
vist[s] = 1;
int cost = d + H(s);
printf("H(s) = %d d = %d \n", H(s), d);
printf("best = %d\tcost = %d\n", best,cost);
debug(s);
if(cost <= best){
best = cost;
for (int i = 0; i < 4; ++i) {
vi t = s;
if(move(t, i)){
printf("moving %c\n", toc(i));
steps.push_back(i);
backtracking(t,steps,d + 1);
steps.pop_back();
}
}
}
}
示例15: merge
vi merge(vi vec, int i, int j) {
if (i > j) swap(i, j);
vec[i] += vec[j];
swap(vec[j], vec.back());
vec.pop_back();
sort(ALL(vec));
return vec;
}