本文整理汇总了C++中vvi::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vvi::size方法的具体用法?C++ vvi::size怎么用?C++ vvi::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vvi
的用法示例。
在下文中一共展示了vvi::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flip
void flip(vvi& g, vvi& revg)
{
for(int i=0;i<g.size();i++)
{
for(int j=0;j<g[i].size();j++)
{
revg[g[i][j]].push_back(i);
}
}
}
示例2: showgraph
void showgraph(vvi& g)
{
for(int i=0;i<g.size();i++)
{
cout<<(i+1)<<" : ";
for(int j=0;j<g[i].size();j++)
cout<<g[i][j]+1<<" ";
cout<<endl;
}
}
示例3: solve
int solve(){
int maxLen = 0;
for( int i = 0; i < map.size(); i++ ){
for( int j = 0; j < map[i].size(); j++ ){
//printf("%3d", dp(i, j));
if( maxLen < dp(i, j) ) maxLen = dp(i, j);
}
}
return maxLen + 1;
}
示例4: solve
void solve() {
for (ui i = 0; i < trees.size(); i++) {
float min = -1;
for (ui j = 0; j < trees.size(); j++) {
if (i == j)
continue;
float dist = calcDist(trees[i][0], trees[i][1], trees[i][2],
trees[j][0], trees[j][1], trees[j][2]);
if (dist < min || min == -1)
min = dist;
}
if (min < 10)
answer[(int) min]++;
}
}
示例5: lcp
int lcp(int x, int y) {
int ret = 0;
if (x == y) return n - x;
for (int k = P.size() - 1; k >= 0 && x < n && y < n; --k)
if (P[k][x] == P[k][y]) {
x += 1 << k;
y += 1 << k;
ret += 1 << k;
}
return ret;
}
示例6: find_sccs
vvi find_sccs(const vvi& adj_list) {
// Reset
num_scc = ticks = 0;
s = stack<int>();
d = vi(adj_list.size(), UNEXPLORED);
low = vi(adj_list.size());
scc = vi(adj_list.size(), NO_SCC);
in_stack = vector<bool>(adj_list.size(), false);
// DFS all nodes
for (int a = 0; a < adj_list.size(); ++a) {
if (d[a] == UNEXPLORED) tarjan(adj_list, a);
}
// Count which scc every node belong to
vvi sccs(num_scc);
for (int i = 0; i < scc.size(); ++i) {
sccs[scc[i]].push_back(i);
}
return sccs;
}
示例7: print
void print (const vvi& s) {
int N = s.size();
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
printf ("%c", s[i][j]);
}
printf ("\n");
}
printf("\n");
}
示例8: flood_fill
void flood_fill(vvi& g)
{
int ct = 0;
memset(&visit,0,sizeof(visit));
for(int i=0;i<g.size();i++)
{
if(!visit[i])
{
dfs(g,i);
ct++;
}
}
cout<<ct<<endl;
}
示例9: c
Matrix operator+(const Matrix& mb)
{
vvi b = mb.a;
int n = a.size();
int m = a[0].size();
Matrix tot;
vvi c(n, std::vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
c[i][j] = a[i][j] + b[i][j];
}
}
tot.a = c;
return tot;
}
示例10: initialize
vvi
initialize(const vvi& P, int m)
{
vvi T;
T.resize(m);
for ( auto i = 0; i < P.size(); ++i )
{
if ( P[i].empty() ) continue;
const auto& L = P[i];
for ( auto j = 0; j < L.size(); ++j )
T[ L[j] ].push_back(i);
}
return T;
}
示例11: fac
// calculate the factorial numbers
// general idea:
// https://blog.codechef.com/2009/07/02/tutorial-for-small-factorials/
// optimization: store all calculated numbers, calculate only when needed
void fac(vvi &f, size_t n) {
for (size_t highest = f.size(); highest < n; ++highest) {
vi current;
const int prev = highest-1;
int carry = 0;
for (vi::iterator it = f[prev].begin(); it != f[prev].end(); ++it) {
int next = *it * (highest+1) + carry;
carry = next / RANGE;
current.push_back(next % RANGE);
}
while (carry) {
current.push_back(carry % RANGE);
carry = carry / RANGE;
}
f.push_back(current);
}
}
示例12: initialize
vvpi initialize(const vvi& P, int m)
{
vvpi T;
T.resize(m);
for ( auto i = 0; i < P.size(); ++i )
{
if ( P[i].empty() ) continue;
auto L = P[i];
sort(L.begin(), L.end());
for ( auto j = 0; j < L.size()-1; ++j )
T[ L[j] ].push_back(make_pair(i, L[j+1]));
T[ L.back() ].push_back(make_pair(i, -1));
}
return T;
}
示例13: componenets
int componenets(vvi& arr){
int r = arr.size();
int c = arr[0].size();
vvi visited(r,vi(c,0));
int curcount = 0;
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
//cout<<i<<" "<<j<< " "<<arr[i][j]<<" "<<visited[i][j]<<endl;
if(arr[i][j]==1 && visited[i][j]==0){
//cout<<i<<" "<<j<<"called"<<endl;
curcount++;
dfs(arr,i,j,r,c,visited);
}
}
}
return curcount;
}
示例14: det
int det(vvi &mat){
int n = mat.size();
int ret = 0, m1, m2;
int i, j;
for(int b = 0; b < n; b++){
m1 = 1, m2 = 1;
for(int k = 0; k < n; k++){
i = k; j = (b+k)%n;
m1 *= mat[i][j];
j = (n-(b+k+1)%n)%n;
m2 *= mat[i][j];
}
ret += m1 - m2;
}
return ret;
}
示例15: backtracking
int backtracking(vvi &table, int i, int j, int count) {
int n = table.size();
int maximum = count;
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj < n; jj++) {
if (is_possible(table, ii, jj)) {
table[ii][jj] = ROOK;
int x = backtracking(table, ii, jj, count + 1);
maximum = x > maximum ? x : maximum;
table[ii][jj] = FREE;
}
}
}
return maximum;
}