$$2015-2016\ ACM-ICPC,\ NEERC,\ Northern\ Subregional\ Contest$$

\(A.Alex\ Origami\ Squares\)

签到

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int main(){
  5. int a,b;
  6. freopen("alex.in","r",stdin);
  7. cin >> a >> b;
  8. freopen("alex.out","w",stdout);
  9. double res = max(max(min(a/3.0,b/1.0),min(a/1.0,b/3.0)),min(a/2.0,b/2.0));
  10. cout << res << endl;
  11. return 0;
  12. }

\(B.Black\ and\ White\)

构造,把多的框在少的里面即可

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 1e5+7;
  6. int n,m,len;
  7. char tile[MAXN][5];
  8. int main(){
  9. #ifdef ONLINE_JUDGE
  10. freopen("black.in","r",stdin);
  11. #endif
  12. ____();
  13. cin >> n >> m;
  14. #ifdef ONLINE_JUDGE
  15. freopen("black.out","w",stdout);
  16. #endif
  17. if(m==0){
  18. cout << 1 << ' ' << 1 << endl << '@' << endl;
  19. return 0;
  20. }
  21. if(n==0){
  22. cout << 1 << ' ' << 1 << endl << '.' << endl;
  23. return 0;
  24. }
  25. char x='@',y='.';
  26. if(n<m){
  27. swap(n,m);
  28. swap(x,y);
  29. }
  30. len = 1;
  31. if(n>m){
  32. tile[len][1] = tile[len][2] = tile[len][3] = y;
  33. len++, m--;
  34. }
  35. while(n>m){
  36. tile[len][2] = x;
  37. tile[len][1] = tile[len][3] = y;
  38. len++, n--;
  39. tile[len][1] = tile[len][2] = tile[len][3] = y;
  40. len++;
  41. }
  42. while(n){
  43. tile[len][1] = tile[len][2] = tile[len][3] = x;
  44. len++, n--;
  45. tile[len][1] = tile[len][2] = tile[len][3] = y;
  46. len++;
  47. }
  48. if(tile[len][1]=='\0') len--;
  49. cout << len << ' ' << 3 << endl;
  50. for(int i = 1; i <= len; i++) cout << (tile[i]+1) << endl;
  51. return 0;
  52. }

\(C.Concatenation\)

答案就是总数量-右串从\(1\)到\(lenr-1\)各个字符在左串\(2~lenl\)之间出现的次数

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 3e5+7;
  6. char s[MAXN],t[MAXN];
  7. int len1,len2;
  8. int main(){
  9. #ifdef ONLINE_JUDGE
  10. freopen("concatenation.in","r",stdin);
  11. #endif
  12. scanf("%s %s",s+1,t+1);
  13. #ifdef ONLINE_JUDGE
  14. freopen("concatenation.out","w",stdout);
  15. #endif
  16. len1 = strlen(s+1);
  17. len2 = strlen(t+1);
  18. int_fast64_t res = len1*(int_fast64_t)len2;
  19. map<char,int> mp;
  20. for(int i = 2; i <= len1; i++) mp[s[i]]++;
  21. for(int i = 1; i < len2; i++) res -= mp[t[i]];
  22. cout << res << endl;
  23. return 0;
  24. }

\(D.Distribution\ in\ Metagonia\)

考虑构造时先把质因子\(2\),\(3\)提出来,然后得到一个奇数,把奇数拆分为\(3^k·p\),继续对\(p\)拆分直到\(p\)的因子只含\(2\)和\(3\)为止

递归构造即可

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. using LL = int_fast64_t;
  6. int t;
  7. LL n[1111];
  8. void gao(LL m, LL mul, vector<LL> &vec){
  9. if(m==1){
  10. vec.emplace_back(mul);
  11. return;
  12. }
  13. if(m%3!=0&&m%2!=0){
  14. LL tp = 1;
  15. while(tp*3<=m) tp *= 3;
  16. gao(tp,mul,vec);
  17. gao(m-tp,mul,vec);
  18. return;
  19. }
  20. LL sum = 1;
  21. while(m%2==0){
  22. sum *= 2;
  23. m >>= 1;
  24. }
  25. while(m%3==0){
  26. sum *= 3;
  27. m /= 3;
  28. }
  29. gao(m,sum*mul,vec);
  30. }
  31. void solve(LL m){
  32. vector<LL> vec;
  33. gao(m,1,vec);
  34. cout << vec.size() << endl;
  35. for(LL x : vec) cout << x << ' '; cout << endl;
  36. }
  37. int main(){
  38. #ifdef ONLINE_JUDGE
  39. freopen("distribution.in","r",stdin);
  40. freopen("distribution.out","w",stdout);
  41. #endif
  42. ____();
  43. cin >> t;
  44. for(int i = 1; i <= t; i++) cin >> n[i];
  45. for(int i = 1; i <= t; i++) solve(n[i]);
  46. return 0;
  47. }

\(E.Easy\ Arithmetic\)

打记号标记前导零、上一位是否是符号、当前正负值然后判断即可

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 3333;
  6. char s[MAXN],tar[MAXN];
  7. int main(){
  8. #ifdef ONLINE_JUDGE
  9. freopen("easy.in","r",stdin);
  10. #endif
  11. ____();
  12. cin >> (s+1);
  13. int len = strlen(s+1);
  14. #ifdef ONLINE_JUDGE
  15. freopen("easy.out","w",stdout);
  16. #endif
  17. int c = 1, ptr = 1;
  18. bool tag = true, lead = true, op = true;
  19. while(ptr<=len){
  20. if(!isdigit(s[ptr])){
  21. if(s[ptr]=='-') tag = false;
  22. else if(s[ptr]=='+') tag = true;
  23. tar[c++] = s[ptr];
  24. op = true;
  25. }
  26. else{
  27. if(op){
  28. op = false;
  29. tar[c++] = s[ptr];
  30. lead = (s[ptr]=='0');
  31. }
  32. else{
  33. if(!tag){
  34. tar[c++] = '+';
  35. tag = true;
  36. tar[c++] = s[ptr];
  37. lead = (s[ptr]=='0');
  38. }
  39. else{
  40. if(lead){
  41. tar[c++] = '+';
  42. lead = (s[ptr]=='0');
  43. tar[c++] = s[ptr];
  44. }
  45. else tar[c++] = s[ptr];
  46. }
  47. }
  48. }
  49. ptr++;
  50. }
  51. cout << (tar+1) << endl;
  52. return 0;
  53. }

\(F.Fygon\)

\(G.Graph\)

友情链接

大顶堆小顶堆维护,做法有点妙

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 1e5+7;
  6. int n,m,k,pre,ord[MAXN],cur,deg[MAXN];
  7. vector<int> G[MAXN];
  8. set<int> S;
  9. set<int,greater<int>> done;
  10. vector<pair<int,int>> edge;
  11. void toposort(int u){
  12. ord[++cur] = u;
  13. pre = u;
  14. for(int v : G[u]) if(--deg[v]==0) S.insert(v);
  15. }
  16. int main(){
  17. #ifdef ONLINE_JUDGE
  18. freopen("graph.in","r",stdin);
  19. freopen("graph.out","w",stdout);
  20. #endif
  21. scanf("%d %d %d",&n,&m,&k);
  22. for(int i = 1; i <= m; i++){
  23. int u, v;
  24. scanf("%d %d",&u,&v);
  25. G[u].emplace_back(v);
  26. deg[v]++;
  27. }
  28. for(int i = 1; i <= n; i++) if(deg[i]==0) S.insert(i);
  29. while(cur<n){
  30. if(S.empty()){ //自己安排下一个节点顺序
  31. int u = *done.begin();
  32. done.erase(u);
  33. edge.emplace_back(make_pair(pre,u));
  34. toposort(u);
  35. }
  36. else if(!k||(S.size()==1&&(done.empty()||*S.begin()>*done.begin()))){
  37. int u = *S.begin();
  38. S.erase(u);
  39. toposort(u);
  40. }
  41. else{
  42. k--;
  43. done.insert(*S.begin());
  44. S.erase(S.begin());
  45. }
  46. }
  47. for(int i = 1; i <= n; i++) printf("%d ",ord[i]); puts("");
  48. printf("%d\n",edge.size());
  49. for(auto p : edge) printf("%d %d\n",p.first,p.second);
  50. return 0;
  51. }

\(H.Hash\ Code\ Hacker\)

每次从后一位向前进一位,后一位\(y\)变成\(Z\),前一位的\(x\)变成\(y\),重复操作即可

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 1111;
  6. char s[MAXN];
  7. int k;
  8. int main(){
  9. #ifdef ONLINE_JUDGE
  10. freopen("hash.in","r",stdin);
  11. #endif
  12. cin >> k;
  13. #ifdef ONLINE_JUDGE
  14. freopen("hash.out","w",stdout);
  15. #endif
  16. for(int i = 1; i <= 999; i++) s[i] = 'x';
  17. s[1000] = 'y';
  18. cout << (s+1) << endl;
  19. for(int i = 1; i < k; i++){
  20. s[1000+1-i] = 'Z';
  21. s[1000-i] = 'y';
  22. cout << (s+1) << endl;
  23. }
  24. return 0;
  25. }

\(I.Insider's\ Information\)

\(J.Journey\ to\ the\ "The World's Start"\)

二分答案之后线段树维护DP求最小耗时

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 1e5+7;
  6. using LL = int_fast64_t;
  7. const LL INF = 0x3f3f3f3f3f3f3f3f;
  8. int n,t,p[MAXN],cost[MAXN];
  9. struct SegmentTree{
  10. LL minn[MAXN<<2];
  11. int l[MAXN<<2],r[MAXN<<2];
  12. #define ls(rt) ((rt) << 1)
  13. #define rs(rt) ((rt) << 1 | 1)
  14. void pushup(int rt){ minn[rt] = min(minn[ls(rt)],minn[rs(rt)]); }
  15. void build(int L, int R, int rt){
  16. l[rt] = L, r[rt] = R;
  17. if(L+1==R) return;
  18. int mid = (L+R) >> 1;
  19. build(L,mid,ls(rt)); build(mid,R,rs(rt));
  20. pushup(rt);
  21. }
  22. void update(int pos, int rt, LL x){
  23. if(l[rt]+1==r[rt]) {
  24. minn[rt] = x;
  25. return;
  26. }
  27. int mid = (l[rt]+r[rt]) >> 1;
  28. if(pos<mid) update(pos,ls(rt),x);
  29. else update(pos,rs(rt),x);
  30. pushup(rt);
  31. }
  32. LL qmin(int L, int R, int rt){
  33. if(l[rt]>=R||L>=r[rt]) return INF;
  34. if(L<=l[rt] && r[rt]<=R) return minn[rt];
  35. return min(qmin(L,R,ls(rt)),qmin(L,R,rs(rt)));
  36. }
  37. }ST;
  38. bool check(int mid){
  39. ST.update(1,1,-1);
  40. for(int i = 2; i <= n; i++) ST.update(i,1,ST.qmin(max(1,i-mid),i,1)+cost[i]);
  41. return ST.qmin(n,n+1,1)+n<=t;
  42. }
  43. int solve(){
  44. int l = 1, r = n-1;
  45. ST.build(1,n+1,1);
  46. while(l<=r){
  47. int mid = (l+r)>>1;
  48. if(check(mid)) r = mid - 1;
  49. else l = mid + 1;
  50. }
  51. return p[l];
  52. }
  53. int main(){
  54. #ifdef ONLINE_JUDGE
  55. freopen("journey.in","r",stdin);
  56. freopen("journey.out","w",stdout);
  57. #endif
  58. scanf("%d %d",&n,&t);
  59. for(int i = 1; i < n; i++) scanf("%d",&p[i]);
  60. for(int i = n-2; i >= 1; i--) p[i] = min(p[i],p[i+1]);
  61. for(int i = 2; i < n; i++) scanf("%d",&cost[i]);
  62. printf("%d\n",solve());
  63. return 0;
  64. }

\(K.Kingdom\ Trip\)

\(L.Lucky\ Chances\)

签到,暴力

  1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
  5. const int MAXN = 111;
  6. const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
  7. int n,m,A[MAXN][MAXN];
  8. int main(){
  9. #ifdef ONLINE_JUDGE
  10. freopen("lucky.in","r",stdin);
  11. #endif
  12. ____();
  13. cin >> n >> m;
  14. for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> A[i][j];
  15. #ifdef ONLINE_JUDGE
  16. freopen("lucky.out","w",stdout);
  17. #endif
  18. int res = 0;
  19. for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
  20. for(int d = 0; d < 4; d++){
  21. bool ok = true;
  22. for(int x = i+dir[d][0], y = j + dir[d][1]; x>0&&x<=n&&y>0&&y<=m; x+=dir[d][0],y+=dir[d][1]) if(A[x][y]>=A[i][j]) ok = false;
  23. res+=ok;
  24. }
  25. }
  26. cout << res << endl;
  27. return 0;
  28. }

2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest (9/12)的更多相关文章

  1. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  2. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  3. 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D】---暑假三校训练

    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D Problem D. Distribution in Metagonia Input ...

  4. 模拟赛小结:2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest

    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest 2019年10月11日 15:35-20:35(Solved 8,Penalty 675 ...

  5. ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个数字c 用 " ...

  6. 2016 NEERC, Northern Subregional Contest G.Gangsters in Central City(LCA)

    G.Gangsters in Central City 题意:一棵树,节点1为根,是水源.水顺着边流至叶子.该树的每个叶子上有房子.有q个询问,一种为房子u被强盗入侵,另一种为强盗撤离房子u.对于每个 ...

  7. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution

    从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...

  8. 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem F. Format

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:1s 空间限制:512MB 题目大意: 给定一个字符串,使用%[...] ...

  9. 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons

    题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个凸多边形,有一种连接两个 ...

随机推荐

  1. Openstack Ocata 负载均衡安装(二)

    Openstack OCATA 负载节点(二) 安装haproxy: apt install haproxy 配置haproxy: vim /etc/haproxy/haproxy.cfg globa ...

  2. Sentry(v20.12.1) K8S 云原生架构探索,SENTRY FOR JAVASCRIPT 故障排除

    系列 Sentry-Go SDK 中文实践指南 一起来刷 Sentry For Go 官方文档之 Enriching Events Snuba:Sentry 新的搜索基础设施(基于 ClickHous ...

  3. 奇技淫巧,还是正统功夫? - Python推导式最全用法

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理. PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取 python免费学习资 ...

  4. Kubernetes 开船记-脚踏两只船:用 master 服务器镜像克隆出新集群

    自从2020年2月23日 园子全站登船 之后,我们一边感叹"不上船不知道,一上船吓一跳" -- kubernetes 比 docker swarm 强大太多,一边有一个杞人忧天的担 ...

  5. React 入门-redux 和 react-redux

    React 将页面元素拆分成组件,通过组装展示数据.组件又有无状态和有状态之分,所谓状态,可以简单的认为是组件要展示的数据.React 有个特性或者说是限制单向数据流,组件的状态数据只能在组件内部修改 ...

  6. SourceGenerator入门指北

    SourceGenerator介绍 SourceGenerator于2020年4月29日在微软的.net blog首次介绍,大概说的是开发者编可以写分析器,在项目代码编译时,分析器分析项目既有的静态代 ...

  7. linux静态库

    库文件可以理解为别人写好的现成的代码,但是看不见源码,只提供程序入口.库又分为动态库和静态库,静态库是在编译的时候将库编译进可执行程序中,运行时不再依赖库文件,而动态库是在运行时加载,运行时需要依赖库 ...

  8. java虚拟机入门(二)-探索内存世界

    上节简单介绍了一下jvm的内存布局以及简单概念,那么对于虚拟机来说,它是怎么一步步的让我们能执行方法的呢: 1.首先,jvm启动时,跟个小领导一样会根据配置参数(没有配置的话jvm会有默认值)向大领导 ...

  9. Vue基础之生命周期函数[残缺版]!

    Vue基础之生命周期函数[残缺版]! 为什么说是残缺版呢?! 因为有一些周期函数我并没有学到!所以是残缺版! 01 beforeCreate //在实例初始化之后,数据观测 (data observe ...

  10. Linux sudo权限提升漏洞整改方法

    一.漏洞概述 1月26日,Sudo发布安全通告,修复了一个类Unix操作系统在命令参数中转义反斜杠时存在基于堆的缓冲区溢出漏洞.当sudo通过-s或-i命令行选项在shell模式下运行命令时,它将在命 ...