2008-2009 ACM-ICPC, NEERC, Southern Subregional Contest
来源:互联网 发布:mac装win10后启动黑屏 编辑:程序博客网 时间:2024/06/06 15:39
http://codeforces.com/gym/101504
这场模拟太多了。
做了两道,B题没有想到什么算法(正解dfs)。
h题也是大模拟,并且很不好写。
k题是最小割(我都快俩月没写图论的玩意了除了搜索。。),没看题。
b可以补一下
k看看。h也看看。
G
给定一个关系网(单向的),问你某个人的朋友的朋友有多少个。
(不能同时为他的朋友,只能是他朋友的朋友)
和今天中午补的那个 合肥的竞赛图有一点像。(那个写t了)
bfs,搞一个层数,统计一下就行。
#include <bits/stdc++.h>using namespace std;const int maxn=100;vector<int>g[maxn];void add(int a,int b){ g[a].push_back(b);}bool vis[maxn];int du[maxn];int m,n,x;int a1;vector<int>v;int main(){ scanf("%d%d",&m,&n); for(int i=1;i<=m;i++){ scanf("%d",&x); for(int j=0;j<x;j++){ scanf("%d",&a1); g[i].push_back(a1); } } memset(du,0,sizeof(du)); memset(vis,false,sizeof(vis)); queue<int>q; q.push(n); vis[n]=true; while(!q.empty()){ int u=q.front(); q.pop(); for(int i=0;i<g[u].size();i++){ int to=g[u][i]; if(!vis[to]){ vis[to]=true; du[to]=du[u]+1; if(du[to]==2){ v.push_back(to); continue; } else{ q.push(to); } } } } printf("%d\n",v.size()); if(v.size()!=0){ sort(v.begin(),v.end()); for(int i=0;i<v.size();i++){ if(i==0) printf("%d",v[i]); else printf(" %d",v[i]); } printf("\n"); } return 0;}
F:
模拟。用stl中的链表(比赛中一顿试,还是不够熟练)
开始想用int 偏移量表示光标的问题, 其实不可以,这点不像vector。
要用一个迭代器搞。
#include <bits/stdc++.h>using namespace std;int main(){ /*s.push_back(2); s.push_back(3); s.push_back(4); s.insert(s.begin(),2); //s. list<int>::iterator it=s.begin(); for(it=s.begin();it!=s.end();it++){ cout<<*it<<endl; }*/ ios::sync_with_stdio(false); string s; list<char>p; cin>>s; list<char>::iterator l=p.begin(); for(int i=0;i<s.length();i++){ if(s[i]!='L'&&s[i]!='R'){ p.insert(l,s[i]); //l++; } else if(s[i]=='L'){ if(l!=p.begin()) l--; } else { if(l!=p.end()) l++; } } list<char>::iterator it; for(it=p.begin();it!=p.end();it++){ cout<<*it; } cout<<endl; return 0;}
补题啊 一定要补题啊!
阅读全文
0 0
- 2008-2009 ACM-ICPC, NEERC, Southern Subregional Contest
- 2009-2010 ACM-ICPC, NEERC, Southern Subregional Contest B kakuro
- 2007-2008 ACM-ICPC, NEERC, Southern Subregional Contest J
- 2012-2013 ACM-ICPC, NEERC, Southern Subregional Contest 解题报告
- 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest J Bottles
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest J dp
- 2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest
- 2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest
- 2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest E
- 2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest C
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest
- 2007-2008 ACM-ICPC, NEERC, Southern Subregional Contest K. Extrasensory Perception(错排)
- 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer
- 电子线路设计技巧7:UC3843A升压电路中振荡频率和占空比的确定方法
- 吴恩达Coursera深度学习课程 DeepLearning.ai 编程作业(4-1)
- wiringpi安装编译问题解决
- 【python】【excel读写 模块】
- 找第一个只出现一次的字符
- 2008-2009 ACM-ICPC, NEERC, Southern Subregional Contest
- java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
- 写给自己
- 变量提升
- 11.14学习心得
- 怎么选择靠谱的IP地理位置定位产品?
- 模板:公式
- linux 工作常用命令
- Java基础——volatile关键字解析