本文整理汇总了C++中si类的典型用法代码示例。如果您正苦于以下问题:C++ si类的具体用法?C++ si怎么用?C++ si使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了si类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: is
inline void is(si &v,int n){
for (int i = 0; i < n; ++i) {
int temp;
scanf("%d",&temp);
v.insert(temp);
}
}
开发者ID:khajaphysist,项目名称:uva,代码行数:7,代码来源:transportation.cpp
示例2: siblings
si siblings(si R) {
si S;
ll sib;
Each(i,R) {
sib = sibling(*i);
if (R.count(sib) == 0)
S.insert(sib);
}
开发者ID:stevenheidel,项目名称:onlinejudge,代码行数:9,代码来源:content.cpp
示例3: top
int top(si &s1, si& s2){
if(!s2.empty())
return s2.top();
if(s1.empty())
return -1;
while(!s1.empty()){
s2.push(s1.top());
s1.pop();
}
return s2.top();
}
开发者ID:poojagarg,项目名称:Coding,代码行数:12,代码来源:queueUsingStacks.cpp
示例4: dfs2
void dfs2(int node, int depth)
{
visited[node] = true;
if(depth == farLen)
worst.insert(node);
if(depth > farLen)
{
farLen = depth;
worst.clear();
worst.insert(node);
}
for(si_it a = adjList[node].begin();
a != adjList[node].end(); ++a)
{
if(!visited[*a])
dfs2(*a, depth + 1);
}
}
开发者ID:Vanslashington,项目名称:algorithm-problem-solutions,代码行数:21,代码来源:theTreeRoot.cpp
示例5: pop
void pop(si &s1, si &s2){
if(!s2.empty()){
s2.pop();
return;
}
if(s1.empty())
return;
while(true){
int i=s1.top();
s1.pop();
if(s1.empty())
return;
s2.push(i);
}
}
开发者ID:poojagarg,项目名称:Coding,代码行数:15,代码来源:queueUsingStacks.cpp
示例6: main
int main()
{
int n,m,x,y,i;
while(scanf("%d%d", &n, &m)!=EOF)
{
vs.clear();
for(i=0; i<n; ++i) v[i].clear();
for(i=0; i<m; ++i)
{
scanf("%d%d", &x, &y);
--x; --y;
v[x].push_back(y);
v[y].push_back(x);
}
for(i=0; i<n; ++i)
{
s1.insert(i);
sort(v[i].begin(), v[i].end());
}
while(!s1.empty())
{
x=*s1.begin();
s1.erase(x);
s2.clear();
q.push(x);
while(!q.empty())
{
x=q.front(); q.pop();
s2.insert(x);
for(sit=s1.begin(); sit != s1.end();)
{
y=*sit;
++sit;
if(!binary_search(v[x].begin(), v[x].end(), y))
{
q.push(y); s1.erase(y);
}
}
}
vs.push_back(s2);
}
printf("%u\n", vs.size());
for(i=0; i<vs.size(); ++i)
{
printf("%u", vs[i].size());
for(sit=vs[i].begin(); sit != vs[i].end(); ++sit)
{
printf(" %d", *sit+1);
}
puts("");
}
}
return 0;
}
开发者ID:AmrARaouf,项目名称:algorithm-detection,代码行数:61,代码来源:1713181.cpp
示例7: main
int main()
{
int cases;
cin >> cases;
int tn;
for(int tcase = 1; tcase <= cases; ++tcase)
{
s1.clear();
s2.clear();
adjList.clear();
adjMat.clear();
parent.clear();
s1Size = 0;
s2Size = 0;
start = 0;
sink = 0;
// Get input, Build adjacency list + matrix
cin >> s1Size;
for(int n = 0; n < s1Size; ++n)
{
scanf("%i", &tn);
s1.insert(tn);
adjList[tn] = si();
adjMat[tn] = mii();
}
cin >> s2Size;
for(int n = 0; n < s2Size; ++n)
{
scanf("%i", &tn);
s2.insert(tn);
adjList[tn] = si();
adjMat[tn] = mii();
for(si_it a = s1.begin(); a != s1.end(); ++a)
if((tn == 0 && *a == 0) || tn == 0 ||
(*a != 0 && tn % (*a) == 0))
{
adjList[*a].insert(tn);
adjMat[*a][tn] = 1;
adjMat[tn][*a] = 1;
}
else
{
adjMat[*a][tn] = 0;
adjMat[tn][*a] = 0;
}
}
for(start = 0; s1.count(start) || s2.count(start); ++start) {}
for(sink = 1; s1.count(sink) || s2.count(sink) ||
sink == start; ++sink) {}
adjList[start] = si();
adjList[sink] = si();
adjMat[start] = mii();
adjMat[sink] = mii();
for(si_it a = s1.begin(); a != s1.end(); ++a)
{
adjList[start].insert(*a);
adjMat[start][*a] = 1;
adjMat[*a][start] = 1;
}
for(si_it a = s2.begin(); a != s2.end(); ++a)
{
adjList[*a].insert(sink);
adjMat[*a][sink] = 1;
adjMat[sink][*a] = 1;
}
// Edmonds Karp's
int maxFlow = 0;
while(true)
{
queue<int> bfsQ;
set<int> visited;
tFlow = 0;
bfsQ.push(start);
visited.insert(start);
while(!bfsQ.empty())
{
int tn = bfsQ.front();
bfsQ.pop();
if(tn == sink)
break;
for(si_it a = adjList[tn].begin();
a != adjList[tn].end(); ++a)
{
if(adjMat[tn][*a] > 0 && !visited.count(*a))
{
//.........这里部分代码省略.........
开发者ID:Vanslashington,项目名称:algorithm-problem-solutions,代码行数:101,代码来源:factorsAndMultiples.cpp
示例8: main
int main()
{
while(cin >> nNodes)
{
worst.clear();
best.clear();
for(int i = 1; i <= nNodes; ++i)
adjList[i].clear();
int nAdj;
for(int n = 1; n <= nNodes; ++n)
{
scanf("%i", &nAdj);
int tempn;
for(int a = 0; a < nAdj; ++a)
{
scanf("%i", &tempn);
adjList[n].insert(tempn);
adjList[tempn].insert(n);
}
}
farLen = farNode = 0;
memset(visited, 0, sizeof(visited));
dfs1(1, 0);
farLen = 0;
memset(visited, 0, sizeof(visited));
dfs2(farNode, 0);
memset(visited, 0, sizeof(visited));
dfs2(*(worst.begin()), 0);
memset(visited, 0, sizeof(visited));
for(int i = 1; i <= nNodes; ++i) height[i] = INF;
dfs3(*(worst.begin()), 0);
int minH = INF+1;
for(int i = 1; i <= nNodes; ++i)
{
if(height[i] == minH)
best.insert(i);
if(height[i] < minH)
{
best.clear();
best.insert(i);
minH = height[i];
}
}
if(nNodes == 1)
{
best.clear();
worst.clear();
best.insert(1);
worst.insert(1);
}
printf("Best Roots :");
for(si_it it = best.begin();
it != best.end(); ++it)
printf(" %i", *it);
cout << endl;
printf("Worst Roots :");
for(si_it it = worst.begin();
it != worst.end(); ++it)
printf(" %i", *it);
cout << endl;
}
return 0;
}
开发者ID:Vanslashington,项目名称:algorithm-problem-solutions,代码行数:78,代码来源:theTreeRoot.cpp
示例9: push
void push(si &s, int i){
s.push(i);
}
开发者ID:poojagarg,项目名称:Coding,代码行数:3,代码来源:queueUsingStacks.cpp
示例10: main
int main()
{
int t;
int ng,nm;
int i,temp;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&ng,&nm);
g.clear(); m.clear();
for(i=0;i<ng;++i)
{
scanf("%d",&temp);
g.insert(temp);
}
for(i=0;i<nm;++i)
{
scanf("%d",&temp);
m.insert(temp);
}
if(solve()) printf("Godzilla\n");
else printf("MechaGodzilla\n");
}
return 0;
}
开发者ID:archiver,项目名称:spoj,代码行数:26,代码来源:army.cpp
示例11: solve
bool solve()
{
int mg,mm;
while(!g.empty() && !m.empty())
{
mg=*g.begin();
mm=*m.begin();
if(mg<mm)
g.erase(g.begin());
else
m.erase(m.begin());
}
return m.empty();
}
开发者ID:archiver,项目名称:spoj,代码行数:15,代码来源:army.cpp
示例12: main
int main(){
int N, n;
int count= 0;
scanf( "%d", &N );
for( int i= 1; i<= N; ++i )
toWrite.insert( i );
for( int i= 1; i<= N; ++i ){
scanf( "%d", &arr[i] );
if( !freq[arr[i]] )
toWrite.erase( arr[i] );
freq[arr[i]]++;
}
//for( auto it= toWrite.begin(); it!= toWrite.end(); ++it )
// cout << *it << " ";
//cout << endl;
for( int i= 1; i<= N; ++i ){
auto it= num.insert( arr[i] );
if( !it.ss || arr[i] > N ){
arr[i]= *(toWrite.begin());
toWrite.erase( arr[i] );
}
}
for( int i= 1; i<= N; ++i )
cout << arr[i] << " ";
return 0;
}
开发者ID:suraj021,项目名称:Codeforces-Solutions,代码行数:42,代码来源:cf569B.cpp.cpp
注:本文中的si类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论