Ejemplo n.º 1
0
void update(char oj,int difpos)
{
    VI::iterator it,it2;
    for(it=pos.begin();it!=pos.end();)
    {
//        printf("*it=%d,difpos=%d\n",*it,difpos);
        if(*it+difpos<alen && *it+difpos>=0 && a[*it+difpos]==oj)
        {
            if(difpos==-1) *it--;
            it++;
        }
        else
        {
//            printf("before erase:%d\n",*it);
//            ans--;
//            it2=it;
//            it++;
//            pos.erase(it2);
//            printf("after erase:%d   it==end()?:%d\n",*it,it==pos.end());
//            printf("it2:after erase:%d   it==end()?:%d\n",*it2,it2==pos.end());
            ans--;
//            printf("before erase:%d\n",*it);
            pos.erase(it);
//            printf("after erase:%d   it==end()?:%d\n",*it,it==pos.end());
        }
    }
}
Ejemplo n.º 2
0
    int getMinimum(vector <int> lines) 
    {		
        target = lines;
        memset(memo, -1, sizeof(memo));
        for(int i=0;i<size(lines);i++) ls.pb(lines[i]);
        ls.pb(0);
        sort(ls.begin(),ls.end());
        ls.erase(unique(ls.begin(), ls.end()), ls.end());

        return go(0,0) - 1;
    }
Ejemplo n.º 3
0
int main() {
    int T; scanf("%d",&T);
    for(int kase = 1;kase <= T;kase++) {
        numy.clear(); numz.clear();
        scanf("%d",&n);
        for(int i = 0;i < n;i++) {
            getPoint(x1[i],y1[i],z1[i]);
            getPoint(x2[i],y2[i],z2[i]);
            numz.PB(z1[i]); numz.PB(z2[i]);
            numy.PB(y1[i]); numy.PB(y2[i]);
        }
        sort(numz.begin(),numz.end());
        sort(numy.begin(),numy.end());
        numz.erase(unique(numz.begin(),numz.end()),numz.end());
        numy.erase(unique(numy.begin(),numy.end()),numy.end());
        printf("Case %d: ",kase);
        cout << solve() << endl;
    }
    return 0;
}
Ejemplo n.º 4
0
int compress(VI& x1,VI& x2, int W){
    VI result;
    REP(i,SZ(x1))for(int d = -1; d <= 1 ;d++){
        int x1n = x1[i]+d; int x2n = x2[i]+d;
        if(0 <= x1n && x1n < W) result.PB(x1n);
        if(0 <= x2n && x2n < W) result.PB(x2n);
    }
    sort(result.begin(), result.end());
    result.erase(unique(result.begin(), result.end()), result.end());
    REP(i,SZ(x1)){
        x1[i] = (int)(find(ALL(result),x1[i]) - result.begin());
        x2[i] = (int)(find(ALL(result),x2[i]) - result.begin());
    }
Ejemplo n.º 5
0
void smooth_path(Network &nw,VI &path,double cutoff){
   // remove points from path which are too close to each other
   int i=1;
   int last=0;
   while (i<(int)path.size()){
      if (norm(nw.nodes[path[i]]-nw.nodes[path[last]])<cutoff){
         path.erase(path.begin()+i);
      } else {
         last=i;
         i++;
      }
   }
}