vector.size()是usigned

BUG:

vector<int>f;


for(int i=0;i<=f.size()-1;++i)

那么当f.size() == 0的时候就跪了

因为f.size()是unsigned 没有 -1

#include <iostream>
#include <cstdio>
#include <set>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define VI vector<int>
#define PB push_back
#define ll(x) (1<<x)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define DWN(i,a,b) for(int i=a;i>=b;--i)
#define clr(f,z) memset(f,z,sizeof(f))

using namespace std;

const int mm = 7009;

int d[mm],l[mm],r[mm],x[mm],vis[mm];
VI level[mm];
int main()
{
    d[0] = 0;
    FOR(i,1,mm-1)///i 对应右下一层的值
    {
        d[i] = d[i-1] + 1;
        if(i&(i-1) == 0)
            ++d[i];
    }
    int n,m;

    while(cin>>n>>m)
    {
        int res = 0,typ,id;
        clr(vis,0);

            FOR(i,1,m)
            {
                cin>>typ;
                if(typ == 1)
                {
                    cin>>id>>l[i]>>r[i]>>x[i];
                    level[id].PB(i);
                }
                else
                {
                    int t,v,ll,rr,ans;
                    cin>>t>>v;
//                    puts("uuu");
                    ++res; ans = 0;
                    ll = rr = v;
                    FOR(j,t,n)
                        for(int k=0;k<=(level[j].size()-1);++k)
                        //FOR(k,0,(level[j].size()-1) )
                        {
                            cout<<level[j].size()<<endl;
                            cout<<j<<"_"<<k<<endl;
                           //cout<<level[j][k]<<endl;
                        }

//                        if(ll>r[ level[j][k] ] || rr < l[ level[j][k] ])
//                            {puts("---"); continue;}
//                        else
//                        {  puts("ooo");
//                            if(vis[ x[ level[j][k] ] ] != res)
//                            {
//                                vis[ x[ level[j][k] ] ] = res;
//                                ++ans;
//                            }
//                            puts("+++");
//                            ll = d[ll-1] + 1;
//                            rr = d[rr];
//                        }
                    cout<<ans<<endl;
                }
            }
    }
    return 0;
}

/**
4 5
1 4 4 7 1
1 3 1 2 2
2 1 1
2 4 1
2 3 3
*/




你可能感兴趣的:(vector.size()是usigned)