本文整理汇总了C++中VVI类的典型用法代码示例。如果您正苦于以下问题:C++ VVI类的具体用法?C++ VVI怎么用?C++ VVI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VVI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: latin_square
latin_square(const VVI& mat, const VI& rp, const VI& cp) : r(mat.size(), 0),
c(mat.size(), 0),
m(mat.size(), VI(mat.size())) {
int n = mat.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
r[i] <<= 3;
r[i] += mat[rp[i]][cp[j]];
c[i] <<= 3;
c[i] += mat[rp[j]][cp[i]];
m[i][j] = mat[rp[i]][cp[j]];
}
}
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:14,代码来源:Towers.cpp
示例2: mul
VVI mul(VVI a, VVI b) {
int m = a.size();
int n = a[0].size();
int p = b.size();
VVI c(m, VI(p, 0));
for (int i = 0; i < m; i++) {
for (int j = 0; j < p; j++) {
for (int k = 0; k < n; k++) {
c[i][j] += a[i][k] * b[k][j];
}
if (c[i][j] > 0) c[i][j] = 1;
}
}
return c;
}
开发者ID:colinlee1999,项目名称:leetcode,代码行数:15,代码来源:547.cpp
示例3: display
void display(VVI v){
for(int i=0;i<v.size();i++){
for(int j=0;j<v[i].size();j++)
printf("%d ", v[i][j]);
printf("\n");
}
}
开发者ID:jiteshsunhala,项目名称:spoj-solutions,代码行数:7,代码来源:GR.cpp
示例4: d1s1
void d1s1(VVI &inp){
int vald1s1 = 0;
int vald1s2 = 0;
int vald2s1 = 0;
int vald2s2 = 0;
int n=inp.size();
int n1 = n-1;
int ij ;
STACK stid1s1,stjd1s1;
STACK stid1s2,stjd1s2;
STACK stid2s1,stjd2s1;
STACK stid2s2,stjd2s2;
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
ij = i-j;
update(inp,stid1s1,stjd1s1,ij,j,vald1s1);
if(i<(n1)){
update(inp,stid1s2,stjd1s2,n1-j,n1-ij,vald1s2);
}
update(inp,stid2s1,stjd2s1,j,n1-ij,vald2s1);
if(i<(n1)){
update(inp,stid2s2,stjd2s2,n1-ij,j,vald2s2);
}
}
emptyStacks(inp,stid1s1,stjd1s1,vald1s1);
emptyStacks(inp,stid1s2,stjd1s2,vald1s2);
emptyStacks(inp,stid2s1,stjd2s1,vald2s1);
emptyStacks(inp,stid2s2,stjd2s2,vald2s2);
}
}
开发者ID:nitin-nizhawan,项目名称:incubator,代码行数:30,代码来源:MAXCROSSv2.0.cpp
示例5: CalcLambda
/// Calc diagonal matrix Lambda
void CalcLambda(const VVI RM, VI & LM) {
if (RM.size() == 0) {
cerr << "Size of relation matrix!" << endl;
exit(-1);
}
LM.clear();
unsigned int i, j;
int sum = 0;
for (i = 0; i < RM.size(); ++i) {
sum = 0;
for (j = 0; j < RM[i].size(); ++j) {
sum += RM[i][j];
}
LM.push_back(sum);
}
}
开发者ID:karthicks123,项目名称:iRoughSet,代码行数:17,代码来源:CRS2.cpp
示例6: GetMinCut
pair<int, VI> GetMinCut(VVI &weights) {
int N = weights.size();
VI used(N), cut, best_cut;
int best_weight = -1;
for (int phase = N-1; phase >= 0; phase--) {
VI w = weights[0];
VI added = used;
int prev, last = 0;
for (int i = 0; i < phase; i++) {
prev = last;
last = -1;
for (int j = 1; j < N; j++)
if (!added[j] && (last == -1 || w[j] > w[last])) last = j;
if (i == phase-1) {
for (int j = 0; j < N; j++) weights[prev][j] += weights[last][j];
for (int j = 0; j < N; j++) weights[j][prev] = weights[prev][j];
used[last] = true;
cut.push_back(last);
if (best_weight == -1 || w[last] < best_weight) {
best_cut = cut;
best_weight = w[last];
}
} else {
for (int j = 0; j < N; j++)
w[j] += weights[last][j];
added[last] = true;
}
}
}
return make_pair(best_weight, best_cut);
}
开发者ID:ISeaTeL,项目名称:Codebook,代码行数:32,代码来源:MinCut.cpp
示例7: solve_impl
int solve_impl(VVI &adj_list, int node, int k) {
int N = adj_list.size();
static VB visited(N);
static VI fn(N), gn(N);
// fn[i] contains no of subtrees rooted at i
// gn[i] contains no of subtrees not rooted at i
visited[node] = true;
VI f_values, g_values;
for (int i = 0; i < adj_list[node].size(); i++) {
int child = adj_list[node][i];
if (!visited[child]) {
solve_impl(adj_list, child, k);
f_values.push_back(fn[child]);
g_values.push_back(gn[child]);
}
}
fn[node] = max(subset_sum_count(f_values, k - 1) + 1, 1);
gn[node] = 0;
for (int i = 0; i < f_values.size(); i++) {
gn[node] += f_values[i] + g_values[i];
}
cout << "fn and gn for " << node << " are " << fn[node] << " " << gn[node]
<< endl;
return fn[node] + gn[node];
}
开发者ID:deepakguptagit,项目名称:practice,代码行数:27,代码来源:solution.cpp
示例8: LCSall
set<VT> LCSall(VT& A, VT& B)
{
VVI dp;
int n = A.size(), m = B.size();
dp.resize(n+1);
for(int i=0; i<=n; i++) dp[i].resize(m+1, 0);
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
if(A[i-1] == B[j-1]) dp[i][j] = dp[i-1][j-1]+1;
else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
set<VT> res;
backtrackall(dp, res, A, B, n, m);
return res;
}
开发者ID:Jestter379,项目名称:Competitive-Programming,代码行数:16,代码来源:LCS.cpp
示例9: can
bool can(int prefLength,VI& result,bool return_result = false){
result.clear();
vector<Hash> hashes;
int n = 1;
for(int sn = 0; sn<n;++sn){
HashComputer<mod1> curHash1;
HashComputer<mod2> curHash2;
for(int i = 0; i < prefLength; ++i){
curHash1.add(a[sn][i]);
curHash2.add(a[sn][i]);
}
hashes.push_back(Hash(make_pair(curHash1.value,curHash2.value),sn,0));
for(int i = prefLength; i < a[sn].size(); ++i){
curHash1.shift(a[sn][i-prefLength],a[sn][i],prefLength);
curHash2.shift(a[sn][i-prefLength],a[sn][i],prefLength);
hashes.push_back(Hash(make_pair(curHash1.value,curHash2.value),sn,i-prefLength+1));
}
}
sort(hashes.begin(),hashes.end());
//hashes.resize(unique(hashes.begin(),hashes.end(),EqualString())-hashes.begin());
VVI results;
for(int i = k-1; i < hashes.size();++i)
if(hashes[i].equals(hashes[i-k+1])){
if(return_result == true){
results.push_back(VI());
int k = results.size()-1;
for(int j = i-n+1; j <=i;++j)
results[k].push_back(hashes[j].pos);
}
else
return true;
}
if(return_result == true){
result = *min_element(results.begin(),results.end());
return true;
}
return false;
}
开发者ID:Yan-Song,项目名称:burdakovd,代码行数:47,代码来源:i.cpp
示例10: print
void print(VVI& v) {
for(int i = 0; i < v.size(); ++i) {
for(int j = 0; j < v[i].size() - 1; ++j) {
cout<<v[i][j]<<" ";
}
cout<<endl;
}
}
开发者ID:xci,项目名称:Tiralabra,代码行数:8,代码来源:slowexact.cpp
示例11: HLD
HLD(VVI adj) {
N = adj.size();
P = PC = VI(N , -1);
LVL = SZ = groupId = groupPos = VI(N , 0);
this->adj = adj;
for(int i = 0; i < N; ++i)
{
if(SZ[i] == 0)
{
initDfs(i);
groups.push_back(VI());
for(int j = i; j != -1; j = PC[j])
groups.back().push_back(j) ,
groupId[j] = groups.size() - 1 ,
groupPos[j] = groups.back().size()-1;
}
}
}
开发者ID:cjtoribio,项目名称:Algorithms,代码行数:18,代码来源:HeavyLightDecomposition.cpp
示例12: OutputMatrix
void OutputMatrix(const VVI matrix) {
unsigned int i, j;
for (i = 0; i < matrix.size(); ++i) {
for (j = 0; j < matrix[i].size(); ++j) {
cout << matrix[i][j] << " ";
}
cout << endl;
}
}
开发者ID:karthicks123,项目名称:iRoughSet,代码行数:9,代码来源:CRS2.cpp
示例13: main
int main()
{
int N, M;
while (cin >> N >> M)
{
int a, b;
VVI w;
VI mr;
VI mc;
w.resize(N);
for (int i = 0; i < N; ++i)
{
w[i].resize(N);
for (int j = 0; j < N; ++j)
{
w[i][j] = 0;
}
}
for (int i = 0; i < M; ++i)
{
cin >> a >> b;
w[a][b] = 1;
}
int numMatches = BipartiteMatching(w, mr, mc);
if (numMatches == N)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}
开发者ID:rhaps0dy,项目名称:UPF-SWERC,代码行数:44,代码来源:12880_bookclub.cpp
示例14: imprime
void imprime(VVI& dist){
const int V = dist.size();
for(int i=0;i<V;++i){
for(int j=0;j<V;++j){
if(dist[i][j]==INF) cout<<"- ";
else cout<<dist[i][j]<< " ";
}
cout<<endl;
}
}
开发者ID:wesklei,项目名称:TEG,代码行数:10,代码来源:Trab_03_Gabriel_Wesklei.cpp
示例15: LCS
VT LCS(VT& A, VT& B)
{
VVI dp;
int n = A.size(), m = B.size();
dp.resize(n+1);
for(int i=0; i<=n; i++) dp[i].resize(m+1, 0);
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
if(A[i-1] == B[j-1]) dp[i][j] = dp[i-1][j-1]+1;
else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
VT res;
backtrack(dp, res, A, B, n, m);
reverse(res.begin(), res.end());
return res;
}
开发者ID:Jestter379,项目名称:Competitive-Programming,代码行数:19,代码来源:LCS.cpp
示例16: transpose
VVI transpose(VVI v){
VVI result;
result.resize(v.size());
for(int i=0;i<result.size();i++)
result[i].resize(v.size());
for(int i=0;i<v.size();i++){
for(int j=0;j<v.size();j++){
result[j][v.size() - 1 - i] = v[i][j];
}
}
return result;
}
开发者ID:jiteshsunhala,项目名称:spoj-solutions,代码行数:12,代码来源:GR.cpp
示例17: check
bool check(const VVI &g)
{
int n = g.size();
allisok = 1;
for (int i = 0; i < n; ++i)
colors[i] = 0;
for (int i = 0; i < n; ++i)
if (colors[i] == 0)
dfs(g, i, 1);
return allisok;
}
开发者ID:dima74,项目名称:Seminars,代码行数:11,代码来源:3v3fast.cpp
示例18: sum_filcol
//SUMA DE MATRICES BAJO EL ENFOQUE FILA-COLUMNA
VVI sum_filcol(VVI A, VVI B)
{
int size=A.size();
VVI rslt(size,VI(size));
for(int i=0;i<size;i++)
for(int j=0;j<size;j++)
rslt[i][j]=A[i][j]+B[i][j];
return rslt;
}
开发者ID:amh28,项目名称:operaciones-en-memoria-cache,代码行数:13,代码来源:naive.cpp
示例19: GetMaxFlow
int GetMaxFlow(int s, int t) {
N = cap.size();
flow = VVI(N, VI(N));
reached = VI(N);
int totflow = 0;
while (int amt = Augment(s, t, INF)) {
totflow += amt;
fill(reached.begin(), reached.end(), 0);
}
return totflow;
}
开发者ID:ksalwa,项目名称:Algorithms,代码行数:12,代码来源:GraphCutInference.cpp
示例20: sum_colfil
//SUMA DE MATRICES BAJO EL ENFOQUE COLUMNA-FILA
VVI sum_colfil(VVI A, VVI B)
{
int size=A.size();
VVI rslt(size,VI(size));
for(int i=0;i<size;i++)
for(int j=0;j<size;j++)
rslt[j][i]=A[j][i]+B[j][i];
return rslt;
}
开发者ID:amh28,项目名称:operaciones-en-memoria-cache,代码行数:13,代码来源:naive.cpp
注:本文中的VVI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论