当前位置: 首页 > news >正文

wordpress dux主题不能用深圳外贸seo

wordpress dux主题不能用,深圳外贸seo,南昌网站建设案例,手机 网站 开发题目链接如下&#xff1a; Online Judge 这道题我一开始的思路大方向其实是对的&#xff0c;但细节怎么实现set到int的哈希没能想清楚&#xff08;没想到这都能用map&#xff09;。用set<string>的做法来做&#xff0c;测试数据小的话答案是对的&#xff0c;但大数据时…

题目链接如下:

Online Judge

这道题我一开始的思路大方向其实是对的,但细节怎么实现set到int的哈希没能想清楚(没想到这都能用map)。用set<string>的做法来做,测试数据小的话答案是对的,但大数据时间超时。

其实就是把所有set一一映射到int, 所以stack里每个元素就是int. 

按照刘汝佳思路写的代码如下(按理每个case里stack应该先清空,但因为题目保证了没有无效操作+只需要最上面set的元素个数,不清空也没问题):

#include <cstdio>
#include <set>
#include <stack>
#include <map>
#include <vector>
// #define debugint T, N, a, b;
std::map<std::set<int>, int> mp;
char op[10];
std::stack<int> s;
std::set<int> empty;
std::vector<std::set<int>> vec;void _push(std::set<int> st){if(!mp.count(st)){vec.push_back(st);mp[st] = vec.size() - 1;}s.push(mp[st]);
}int main(){#ifdef debugfreopen("0.txt", "r", stdin);freopen("1.txt", "w", stdout);#endifscanf("%d", &T);while(T--){scanf("%d", &N);vec.clear();mp.clear();while(N--){scanf("%s", op);if(op[0] == 'P'){_push(empty);} else{a = s.top();s.pop();if(op[0] == 'D'){s.push(a);s.push(a);} else{b = s.top();s.pop();std::set<int> tmp;if(op[0] == 'A'){tmp = vec[b];tmp.insert(a);} else{if(op[0] == 'U'){tmp = vec[a];for(auto it = vec[b].begin(); it != vec[b].end(); ++it){tmp.insert(*it);}} else if(op[0] == 'I'){for(auto it = vec[a].begin(); it != vec[a].end(); ++it){if(vec[b].find(*it) != vec[b].end()){tmp.insert(*it);}}}}_push(tmp);}}printf("%d\n", vec[s.top()].size());}printf("***\n");}#ifdef debugfclose(stdin);fclose(stdout);#endifreturn 0;
}

原先的代码如下(超时):

#include <cstdio>
#include <set>
#include <stack>
#include <string>
// #define debugint T, N;
char op[10];
std::stack<std::set<std::string>> s, empStack;
std::set<std::string> a, b, empty;std::string toString(std::set<std::string> st){std::string str = "{";for(auto it = st.begin(); it != st.end(); ++it){str += (it == st.begin() ? "" : ",");str += *it;}return str + "}";
}int main(){#ifdef debugfreopen("0.txt", "r", stdin);freopen("1.txt", "w", stdout);#endifscanf("%d", &T);while(T--){scanf("%d", &N);s.swap(empStack);while(N--){scanf("%s", op);if(op[0] == 'P'){s.push(empty);} else{a = s.top();s.pop();if(op[0] == 'D'){s.push(a);s.push(a);} else{b = s.top();s.pop();if(op[0] == 'A'){b.insert(toString(a));s.push(b);} else{if(op[0] == 'U'){for(auto it = a.begin(); it != a.end(); ++it){b.insert(*it);}s.push(b);} else if(op[0] == 'I'){std::set<std::string> intersect;for(auto it = a.begin(); it != a.end(); ++it){if(b.find(*it) != b.end()){intersect.insert(*it);}}s.push(intersect);}}}}printf("%d\n", s.top().size());}printf("***\n");}#ifdef debugfclose(stdin);fclose(stdout);#endifreturn 0;
}

http://www.mmbaike.com/news/32350.html

相关文章:

  • 网站打开慢什么原因呢怎样查询百度收录和排名情况
  • 3有免费建网站seo课程培训课程
  • 别人做的网站不能用windows优化大师可靠吗
  • wordpress 竖导航栏seo推广哪家公司好
  • 创建手机网站seo主要优化哪些
  • 中文网站建设中临汾网络推广
  • 明年做哪个网站能致富网站优化的方法有哪些
  • 北京商标注册优化关键词的作用
  • 商业设计平面图seo网站优化推广
  • 广州网站建设网页制作开发万网创始人
  • wordpress制作教程视频win7优化配置的方法
  • 私域视频北京seo百科
  • 市住房和城乡建设局网站百度一下你就知道官方
  • 服务器怎么运行网站新闻稿范文300字
  • 企业管理咨询网站模板百度网站的域名地址
  • 沈阳网站建设建设公司排名网站被禁用如何解决
  • 中文域名抢注的骗局百度推广seo优化
  • 大连金州新区规划建设局网站免费的网页设计成品下载
  • 网站数据库设置权限seminar什么意思中文
  • 揭阳市住房和城乡建设局网站环球资源网官方网站
  • 网站策划的最终体现会计培训班一般多少钱
  • 青岛建设银行网站政府免费培训面点班
  • 电子商务网站seo希爱力副作用太强了
  • 一品威客网是做啥的网站小说关键词生成器
  • aspcms 网站搬家提升关键词
  • 如何做网站301重定向seo诊断站长
  • wordpress链接数据库文件seo关键词优化排名软件
  • 公司企业邮箱登录海外网站推广优化专员
  • 临湘网站网上销售培训课程
  • 潍坊优化网站排名靠前苏州网站建设书生