本文整理汇总了C++中vi::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vi::size方法的具体用法?C++ vi::size怎么用?C++ vi::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vi
的用法示例。
在下文中一共展示了vi::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isPrime
bool isPrime(ll N){
if(N <= SIEVE_MAX) return _prime[N];
for(int i = 0; i<(int) primes.size(); i++){
if(N%primes[i] == 0) return false;
}
return true;
}
示例2: query
bool query(const vvpi& T, const vi& Qin)
{
if ( Qin.empty() ) return true;
if ( Qin.size() == 1 ) return !T[ Qin[0] ].empty();
auto Q = Qin; // copy the query
sort(Q.begin(), Q.end());
for ( auto p : T[ Q[0] ] )
{
int i, k; tie(i, k) = p;
int s = 1;
while ( k <= Q[s] && k > -1 )
{
s += k == Q[s];
if ( s == Q.size() )
return true;
auto it = lower_bound( T[k].begin(), T[k].end(), i,
[](const pi& x, int val) -> bool { return x.first < val; } );
if (it == T[k].end() || it->first != i)
break;
k = it->second;
}
}
return false;
}
示例3: nests
bool nests(vi &a, vi &b) {
for (int i = 0; i < a.size(); i++) {
if (a[i] >= b[i]) return false;
}
return true;
}
示例4: toString
//debugging purpose
void toString(){
cerr << "Call name: " << call_fun_name << " | Functions: ";
for(vs::iterator i = function_uses.begin(); i != function_uses.end(); i++){
cerr << *i << " ";
}
cerr << "| Pairs Size " << pairs.size() << endl;
}
示例5: 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;
}
示例6: main
int main()
{
vi dist;
int tested;
scanf("%d", &tested);
while(tested--)
{
lista.assign(MAX*MAX, vi());
dist.assign(MAX*MAX, -1);
toposort.clear();
string name;
cin>>name>>row>>column;
int n=0;
for(int i=0;i<row;i++)
for(int j=0;j<column;j++)
scanf("%d", &a[i][j]), b[i][j]=n++;
generate(n);
int ans=-1;
for(int i=0;i<toposort.size();i++)//MAX path
{
int u=toposort[i];
ans=min(ans , dist[u]);
for(int j=0;j<lista[u].size();j++)
{
int v=lista[u][j];
dist[v]=min(dist[v], dist[u] - 1); // update distance
}
}
cout<<name<<": "<<-ans<<endl;
}
}
示例7: reduce
int reduce(vi arr1, vi arr2) {
int answ = 0;
for(int i=0; i<arr1.size(); i++)
answ += max(arr1[i], arr2[i]);
return answ;
}
示例8: process
vi process(vi input)
{
int sz= input.size();
int t= 0;
vi uInX(n), uOutX(n), uInY(m), uOutY(m);
if (sz==n)
{
initX(input,uInX,uOutX);
calcY(uInX,uOutX,uInY,uOutY);
}
else
{
initY(input,uInY,uOutY);
calcX(uInX,uOutX,uInY,uOutY);
calcY(uInX,uOutX,uInY,uOutY);
}
bool f= 0;
while (!f)
{
f= calcX(uInX,uOutX,uInY,uOutY);
f&= calcY(uInX,uOutX,uInY,uOutY);
}
return uOutY;
}
示例9: seive
void seive(){
isPrime.assign(MAX_N, 1);
markP(2);
for(int i = 3; i < (int)isPrime.size(); i++)
if(isPrime[i])
markP(i);
}
示例10: main
int main() {
fibo.push_back(0);
int A = 1;
int B = 2;
fibo.push_back(1);
fibo.push_back(2);
int C;
do {
C=A+B;
if(C > MAXVAL) break;
fibo.push_back(C);
A=B;
B=C;
}while(true);
int T;
int X,K;
scanf("%d",&T);
while(T--) {
scanf("%d %d",&X,&K);
printf("%llu\n",part(X,fibo.size()-1,K));
}
return 0;
}
示例11: topsort
void topsort(vvi &adj, int node, vi ind, vb vis, vi res){
vis[node] = 1;
res.push_back(node);
for(int i=0; i< adj[node].size();i++){
int v = adj[node][i];
if(!vis[v])
ind[v]--;
}
for(int i=0; i<len;i++){
if (!vis[i] && (ind[i] == 0))
topsort(adj, i, ind, vis, res);
}
if (res.size() == len){
cont++;
cout << mapi1[res[0]];
for(int i=1; i<len;i++)
cout << ' ' << mapi1[res[i]];
cout << '\n';
return;
}
}
示例12:
SegmentTree(const vi&_A)
{
A=_A;
n=int(A.size());
st.assign(4*n,0);
build(1,0,n-1);
}
示例13: has
bool has(vi v, int e)
{
for (int i = 0; i < (int) v.size(); i++)
if (v[i] == e)
return true;
return false;
}
示例14: vi
noq_st(vi a){
og = a;
n = og.size();
st = vi(4 * n);
lazy = vi(4 * n);
build(0, 0, n - 1);
}
示例15: 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);
}