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


C++ set::emplace方法代码示例

本文整理汇总了C++中set::emplace方法的典型用法代码示例。如果您正苦于以下问题:C++ set::emplace方法的具体用法?C++ set::emplace怎么用?C++ set::emplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在set的用法示例。


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

示例1: dfs

 void dfs(char c, int i,int j,int id,set<II>& S) {
   S.emplace(i,j);
   cid[i][j]=id;
   FORR(m,moves) {
     int i2=i+m.first,j2=j+m.second;
     if(i2<0||i2>=N||j2<0||j2>=N) continue;
     if(B[i2][j2]!=c) continue;
     if(cid[i2][j2]!=-1) continue;
     S.emplace(i2,j2);
     cid[i2][j2]=id;
     dfs(c,i2,j2,id,S);
   }
开发者ID:k-ori,项目名称:topcoder-offline,代码行数:12,代码来源:FoxAndGo2.cpp

示例2: main

int main()
{
//    Open();
    int n, q;
    int cas = 0;
    while(~scanf("%d%d", &n,&q))
    {
        cas++;
        Tn = 0;
        tot = 0;
        for(int i = 0; i <= n; i++) G[i].clear();
        for(int i = 1; i < n; i++)
        {
            int u, v;
            scanf("%d%d", &u,&v);
            G[u].push_back(v);
            G[v].push_back(u);
        }
        dfs(1, -1, 0);
        dfsSeg(1, -1);

        int last = 0;
        while(q--)
        {
            int k, p, t;
            scanf("%d%d%d", &k, &p, &t);
            t--;
            S.clear();
            p += last;
            p = p%n+1;
            for(int i = 0; i < k; i++)
            {
                int x;
                scanf("%d", &x);
                bool flag = true;
                it = it1 = S.upper_bound(PII(st[x], 0));
                it2 = S.upper_bound(PII(ed[x], 0));
                if(it != S.begin()) it--;
                else flag = false;
                S.erase(it1, it2);
                if(!flag || !(it->first <= st[x] && it -> second >= ed[x]))
                    S.emplace(st[x], ed[x]);
            }
            int pre = 1;
            int ans = -1;
            for(it1 = S.begin(); it1 != S.end(); it1++)
            {
                int l = it1->first;
                if(pre < l) ans = res(ans, query(T[p], pre, l-1, t, 0), t);//, printf("%d, %d\n", pre, l-1);
                pre = it1->second + 1;
            }
            if(pre <= Tn) ans = res(ans, query(T[p], pre, Tn, t, 0), t);//, printf("%d, %d\n", pre, Tn);
            printf("%d\n", ans);
            last = max(ans, 0);
        }
    }
    return 0;
}
开发者ID:qingping95,项目名称:ACM,代码行数:58,代码来源:HDU5756主席树-区间修改静态标记.cpp

示例3: loadWords

 void loadWords(const string &input, set<dictTuple> &textWords) {
     ifstream fin(input);
     if (!fin.is_open()) {
         throw invalid_argument("File" + input + " Not Found");
     }
     cout << "Loading file: " + input << endl;
     string buf;
     regex e(wordRegex, regex_constants::extended);
     while (getline(fin, buf)) {
         smatch match;
         regex_search(buf, match, e);
         for (auto word:match) {
             string tmp(word.str());
             transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
             textWords.emplace(tmp, false);
         }
     }
     textWords.erase(dictTuple("", 0));
 }
开发者ID:futures-dev,项目名称:Homework,代码行数:19,代码来源:Dictionary.hpp

示例4: getId

 int getId(TreeNode* p) {
     int ret;
     if (p == nullptr) {
         ret = -1;
     } else {
         pair<int, pair<int, int>> key;
         key.first = p->val;
         key.second.first = getId(p->left);
         key.second.second = getId(p->right);
         if (mp.count(key) > 0) {
             ret = mp[key];
         } else {
             ret = mp.size();
             mp[key] = ret;
         }
         // printf("%d => %d\n", p->val, ret);
     }
     ids.emplace(ret);
     return ret;
 }
开发者ID:watashi,项目名称:AlgoSolution,代码行数:20,代码来源:572.cpp


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