当前位置: 首页>>代码示例>>C++>>正文


C++ ST类代码示例

本文整理汇总了C++中ST的典型用法代码示例。如果您正苦于以下问题:C++ ST类的具体用法?C++ ST怎么用?C++ ST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: countDescendants

	vector <string> countDescendants(vector <string> parentData)
	{
		f = true;
		vector <string> ret, fail;
		ST tmp = "";
		tr(it, parentData)	tmp += *it;
		
		while(tmp.length() > 0)
		{
			int idx = tmp.find(' ');
			vs.pb(tmp.substr(0, idx));
			if(idx == string::npos)	break;
			tmp = tmp.substr(idx+1);
		}

		sort(all(vs));
		vs.resize(unique(all(vs)) - vs.begin());

		tr(it, vs)
		{
			int idx = it->find(',');
			ST ch = it->substr(0, idx), par = it->substr(idx+1);
			cnt[ch] = cnt[par] = 0;
			g[par].pb(ch);
		}
开发者ID:Jadnap,项目名称:My_TopCoder_Codes,代码行数:25,代码来源:HierarchicalTree.cpp

示例2: main

int main()
{
	int N;
	ST st;

	cin >> N >> st;

	map <char, int> mp;

	forn(i, st.size())
		mp[st[i]]++;

	ST ret;
	tr(it, mp) {
	       	if(it->second % N != 0 ) {
			cout << -1 << endl;
			return 0;
		}
		forn(i, it->second/N)
			ret += it->first;
	}
	forn(i, N)
		cout << ret;
	cout << endl;

	return 0;
}
开发者ID:Jadnap,项目名称:CodeForces,代码行数:27,代码来源:A.cpp

示例3: set_data_costs

/** Set the data costs of the MRF. */
void
set_data_costs(std::vector<FaceInfo> const & face_infos, ST const & data_costs,
    std::vector<mrf::Graph::Ptr> const & mrfs) {

    /* Set data costs for all labels except label 0 (undefined) */
    for (std::size_t i = 0; i < data_costs.rows(); i++) {
        ST::Row const & data_costs_for_label = data_costs.row(i);

        std::vector<std::vector<mrf::SparseDataCost> > costs(mrfs.size());
        for(std::size_t j = 0; j < data_costs_for_label.size(); j++) {
            const std::size_t id = data_costs_for_label[j].first;
            const float data_cost = data_costs_for_label[j].second;
            const std::size_t component = face_infos[id].component;
            const std::size_t cid = face_infos[id].id;
            //TODO change index type of mrf::Graph
            costs[component].push_back({static_cast<int>(cid), data_cost});
        }

        int label = i + 1;

        for (std::size_t j = 0; j < mrfs.size(); ++j) {
            mrfs[j]->set_data_costs(label, costs[j]);
        }
    }

    for (std::size_t i = 0; i < mrfs.size(); ++i) {
        /* Set costs for undefined label */
        std::vector<mrf::SparseDataCost> costs(mrfs[i]->num_sites());
        for (std::size_t j = 0; j < costs.size(); j++) {
            costs[j].site = j;
            costs[j].cost = MRF_MAX_ENERGYTERM;
        }
        mrfs[i]->set_data_costs(0, costs);
    }
}
开发者ID:swayfreeda,项目名称:mvs-texturing-parsing,代码行数:36,代码来源:view_selection.cpp

示例4: escapeCStringTpl

inline ST escapeCStringTpl(const ST &ba)
{
    ST ret;
    ret.reserve(ba.length() * 2);
    for (int i = 0; i < ba.length(); ++i) {
        CT c = ba.at(i);
        switch (c) {
            case '\\': ret += "\\\\"; break;
            case '\a': ret += "\\a"; break;
            case '\b': ret += "\\b"; break;
            case '\f': ret += "\\f"; break;
            case '\n': ret += "\\n"; break;
            case '\r': ret += "\\r"; break;
            case '\t': ret += "\\t"; break;
            case '\v': ret += "\\v"; break;
            case '"': ret += "\\\""; break;
            default:
                if (c < 32 || c == 127) {
                    ret += '\\';
                    ret += '0' + (c >> 6);
                    ret += '0' + ((c >> 3) & 7);
                    ret += '0' + (c & 7);
                } else {
                    ret += c;
                }
        }
开发者ID:anchowee,项目名称:QtCreator,代码行数:26,代码来源:gdbmi.cpp

示例5: QScriptValue

    QScriptValue convert_script_value_f_size<ST>::operator()(QScriptEngine*eng,
							   const ST & s) const
    {
	QScriptValue obj = eng->newObject();
	obj.setProperty("width", QScriptValue(eng, s.width()));
	obj.setProperty("height", QScriptValue(eng, s.height()));
	return obj;
    }
开发者ID:Mr-Kumar-Abhishek,项目名称:qboard,代码行数:8,代码来源:ScriptQt.cpp

示例6: countInv

int countInv(ST st) {
	int ret = 0;
	forn(i, st.size()) 
		forab(j, i+1, st.size() - 1)
			if(st[j] < st[i])
				ret++;
	return ret;
}
开发者ID:Jadnap,项目名称:My_TopCoder_Codes,代码行数:8,代码来源:StrIIRec.cpp

示例7: add

int PermutationSum::add (int n) 
{
	SS ss;
	ss << n;
	ST st;
	st = ss.str();
	sort(all(st));
	cout << ss.str() << endl;
	int ret = 0;
	
	do {
		ret += atoi(st.c_str());
	} while(next_permutation(all(st)));
	
	return ret;
}
开发者ID:Jadnap,项目名称:My_TopCoder_Codes,代码行数:16,代码来源:PermutationSum.cpp

示例8: main

int main(){
    scanf("%d%d", &N, &Q);
    M = 1;
    while(M < N) M <<= 1;
    ST st = ST();
    for(int i = 0; i < N; i++){
        int h; scanf("%d", &h);
        st.update(h, i);
    }
    while(Q--){
        int a, b; scanf("%d%d", &a, &b);
        a--;
        //        cerr << a << " " << b << " " << st.get_max(a,b) << " " << st.get_min(a,b) << endl;
        printf("%d\n", st.get_max(a,b)-st.get_min(a,b));
    }
    return 0;
}
开发者ID:hadrori,项目名称:hadrori.github.io,代码行数:17,代码来源:3264.cpp

示例9: isolate_unseen_faces

/** Remove all edges of nodes which corresponding face has not been seen in any texture view. */
void
isolate_unseen_faces(UniGraph * graph, ST const & data_costs) {
    int num_unseen_faces = 0;
    for (std::uint32_t i = 0; i < data_costs.cols(); i++) {
        ST::Column const & data_costs_for_face = data_costs.col(i);

        if (data_costs_for_face.size() == 0) {
            num_unseen_faces++;

            // get all the adjacent facets of the i-the facet // each facet is corresponding to
            // the a node in the UnifindGraph
            std::vector<std::size_t> const & adj_nodes = graph->get_adj_nodes(i);
            for (std::size_t j = 0; j < adj_nodes.size(); j++)
                graph->remove_edge(i, adj_nodes[j]);
        }

    }
    std::cout << "\t" << num_unseen_faces << " faces have not been seen by a view." << std::endl;
}
开发者ID:swayfreeda,项目名称:mvs-texturing-parsing,代码行数:20,代码来源:view_selection.cpp

示例10: main

int main()
{
	setlocale( LC_ALL, "Russian" );
	ST obj;
	cout << "Введите значение х (количество элементов в первом массиве): " << endl;
	int x;
	cin >> x;
	if(x <= 0)
	{
		cout << "х должен быть положительным числом! " << endl;
	}
	else
	{
		cout << endl;
		cout << "Начальный массив: " << endl;
		obj.set(x);
		cout << "Массив после сортировки: " << endl;
		obj.sort(x);
	}
	getch();
	return 0;
	
}
开发者ID:YanaFedorova,项目名称:2_term,代码行数:23,代码来源:1task.cpp

示例11: main13123131

int main13123131(int argc, const char * argv[])
{
    srand((unsigned)time(NULL));
    int N;
    N = 100000;
    clock_t begin,end;
    ST st;
    for (int i=0;i<N;i++)
    {
        Item it;
        it.rand();
  //      cout<<it.key()<<" "<<it.INFO()<<endl;
        st.insert(it);
    }
    Key v = 0;
    double result = 0;
    for (int i = 0; i < 10000; i++) {
        v=1 + (int) (element * (::rand() / (RAND_MAX + 1.0)));
        begin = clock();
        st.search(v);
        end = clock();
        double t = double (end-begin)/CLOCKS_PER_SEC * 1000;
        result += t;
    }
    result=result/10000*1000;
    
    cout<<"ST contains: "<<st.count()<<" elements"<<endl;
  //  if (result.null())
  //  cout<<"Can not find the Key:"<<v;
  //  else
  //  cout<<"Key: "<<result.key()<<" Value:"<<result.INFO();
   // double timeConsumed_ = double (end-begin)/CLOCKS_PER_SEC * 1000;
    cout<<endl<<result<<" ms";
    
    return 0;
    
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例12: maxCities

 int maxCities(int n, vector<int> a, vector<int> b, vector<int> len) {
     if (n <= 2) return n;
     
     vector<vector<int>> adjNode(n);
     for (int i = 0; i < n-1; ++i) {
         --a[i];
         --b[i];
         adjNode[a[i]].push_back(b[i]);
         adjNode[b[i]].push_back(a[i]);
         distMap[{a[i], b[i]}] = len[i];
         distMap[{b[i], a[i]}] = len[i];
     }
     
     int maxCount = 2;
     
     for (int i = 0; i < n; ++i) {
         Mii m;
         for (int j : adjNode[i]) {
             Si s;
             // node, parent
             ST<Pii> st;
             Vi d(n, -1);
             d[i] = 0;
             st.emplace(j, i);
             while (!st.empty()) {
                 Pii p = st.top();
                 d[p.first] = dist(p.first, p.second) + d[p.second];
                 s.insert(d[p.first]);
                 st.pop();
                 for (int k : adjNode[p.first]) {
                     if (k == p.second) continue;
                     st.emplace(k, p.first);
                 }
             }
             for (int dd : s) {
                 if (m.count(dd)) {
                     ++m[dd]; 
                 } else m[dd] = 1;
             }
         }
         for (Pii t : m) {
             if (t.second > maxCount) maxCount = t.second;
         }
     }
     
     return maxCount;
 }
开发者ID:antoshkaplus,项目名称:CompetitiveProgramming,代码行数:47,代码来源:630.2.Egalitarianism.cpp

示例13: bar

// CK2-LABEL: _Z3bari
int bar(int arg){
  ST<int> A;
  return A.foo(arg);
}
开发者ID:CSI-LLVM,项目名称:clang,代码行数:5,代码来源:target_update_codegen.cpp

示例14: present

#define pb		push_back

#define	present(x, c)	((c).find(x) != (c).end())	//map & set//
#define	cpresent(x, c)	(find( (c).begin(), (c).end(), x) != (c).end())	//vector & list//

#define read(n)		scanf("%d", &n)
#define write(n)	printf("%d ", n)
#define writeln(n)	printf("%d\n", n)

#ifdef DEBUG
	#undef DEBUG
#endif
#define DEBUG

ST s, t;
vi mx, mn;
vector <bool> in;

int main()
{
	cin >> s >> t;
	DEBUG(s);
	DEBUG(t);

	mx.resize(s.size(), 0);
	mn.resize(s.size(), t.size());
	in.resize(s.size(), false);

	if(s.size() < t.size() || s.front() != t.front() || s.back() != t.back()) {
		DEBUG("#0");
开发者ID:Jadnap,项目名称:CodeForces,代码行数:30,代码来源:D.cpp

示例15: maintest

int maintest()
{
    srand((unsigned)time(NULL));
 //   clock_t begin,end;
  /*  ST st;
    
    //INSERT ELEMENTS
    for (int i=0;i<N;i++)
    {
        Item it(i,i*0.1);
        
        //      cout<<it.key()<<" "<<it.INFO()<<endl;
        st.insert(it);
    }
    
    
    Key v = 0;
    double result = 0;
    
    for (int i = 0; i < repeat; i++) {
        v=1 + (int) (N * (::rand() / (RAND_MAX + 1.0)));
        begin = clock();
        st.search(v).INFO();
        end = clock();
        double t = double (end-begin)/CLOCKS_PER_SEC * 1000;
        result += t;
    }
    result=result/repeat;
    cout<<"ST contains: "<<st.count()<<" elements"<<endl;
    cout<<"The search cost "<<result<<" ms";
    */
    
    /*
     Binary search st
     */
    
    int key_[N];
    float val_[N];
    for (int i=0; i<N ; i++) {
        key_[i] = 0;
        val_[i] = 0;
    }
    ST bsst;
    for (int i=0; i<N; i++) {
        Item item(i,i*0.1);
        //insert items
        if (binarysearch2(item.key(),0, bsst.count(),key_) == -1) {
            int j=bsst.count();
            while(item.key()<key_[j-1]) {
                if(j==0)
                    break;
                key_[j]=key_[j-1];
                val_[j]=val_[j-1];
                j--;
            }
            key_[j]=item.key();
            val_[j]=item.INFO();
        }
        else {
            val_[binarysearch2(item.key(),0, bsst.count(),key_)] = item.INFO();
        }
        bsst.insert(item);
    }
   
    Key v = 0;
    double result = 0;
    clock_t begin,end;
    begin = clock();
    for (int i = 0; i < repeat; i++) {
        v=1 + (int) (N * (::rand() / (RAND_MAX + 1.0)));
        Item x = bsst.search(N/2);
    }
    end = clock();
    result=double (end-begin)/CLOCKS_PER_SEC * 1000;
    cout<<"ST contains: "<<bsst.count()<<" elements"<<endl;
    cout<<"The search cost "<<result<<" ms";

    

    
    result = 0;
    int max = bsst.count()-1;
    begin = clock();
    for (int i=0; i <repeat; i++) {
        v=1 + (int) (N * (::rand() / (RAND_MAX + 1.0)));
        binarysearch2(max,0, max,key_);
    }
    end = clock();
    result=double (end-begin)/CLOCKS_PER_SEC * 1000;
   // result=result/repeat;
     
    
    cout<<endl<<"BSST contains: "<<bsst.count()<<" elements"<<endl;
    cout<<"The search cost "<<result<<" ms";
    
    
    
    return 0;
    
}
开发者ID:,项目名称:,代码行数:100,代码来源:


注:本文中的ST类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。