第001话 宝可梦,就决定是你了!

等差数列求和公式

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>using namespace std;int main() {long long n;cin >> n;cout << n*n;return 0;
}

第002话 宝可梦中心大对决!

如果两数互质连一条边,找一个点尽量多的子图,点两两间都有边。

就是最大团,可以用Bron–Kerbosch算法

#include <cstdio>
#include <iostream>
#include <algorithm>using namespace std;
/*int n,a[100],g[30][30];
int tp,s[100],ans;int dfs(int st) {for (int i = st; i <= n; i++) {bool ok = 1;for (int j = 1; j <= tp; j++) if (g[s[j]][i] != 1) {ok = 0;break;}if (ok) {s[++tp] = i;if (tp > ans) ans = tp;dfs(i+1);}}}
*/int gcd(int a,int b) {return b==0 ? a : gcd(b,a%b);
}#define N 1010
bool flag[N], a[N][N];
int ans, cnt[N], group[N], n, vis[N];  bool dfs( int u, int pos ){  int i, j;  for( i = u+1; i <= n; i++){  if( cnt[i]+pos <= ans ) return 0;  if( a[u][i] ){  // 与目前团中元素比较,取 Non-N(i)   for( j = 0; j < pos; j++ ) if( !a[i][ vis[j] ] ) break;   if( j == pos ){     // 若为空,则皆与 i 相邻,则此时将i加入到 最大团中   vis[pos] = i;  if( dfs( i, pos+1 ) ) return 1;      }      }  }      if( pos > ans ){  for( i = 0; i < pos; i++ )  group[i] = vis[i]; // 最大团 元素   ans = pos;  return 1;      }      return 0;
}
void maxclique()
{  for (int i = 0; i <= n; i++) vis[i] = cnt[i] = group[i] = flag[i] = 0;ans=-1;  for(int i=n;i>0;i--)  {  vis[0]=i;  dfs(i,1);  cnt[i]=ans;  }
}  void work() {cin >> n;int s[100];for (int i = 1; i <= n; i++) cin >> s[i];//sort(a+1,a+n+1);for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++) {a[i][j] = (gcd(s[i],s[j])==1);//  cout<<i<<" "<<j<<" "<<a[i][j]<<"\n";}maxclique(); printf("%d\n",ans);
}int main() {int T;cin >> T;while(T--) work();return 0;
}

第003话 收服宝可梦吧!

送分

有不一样肯定第一个串放弃一位

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;char s1[2100000],s2[2100000];void work() {scanf("%s%s",s1,s2);int l1 = strlen(s1),l2 = strlen(s2);if (l1 != l2+2) {puts("0");} else {int i = 0,j = 0,t = 0;while (i <= l1 && j <= l2) {if (s1[i] == s2[j]) {i++;j++;} else {t++;i++;}}// cout<<t<<" "<<l1<<" "<<i<<" "<<j<<"\n";if (t+l1+1-i == 2) puts("1");else puts("0");}
}int main() {int T;cin >> T;while(T--) work();return 0;
}

第004话 武士少年的挑战!

送分

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;int a[100];int main() {for (int i = 1; i <= 18; i++) {int x;cin >> x;a[x]++;}int ans = 18;for (int i = 1; i <= 13; i++) if (a[i]==2 || a[i]==3) ans -= 2;else if(a[i] == 4) ans -= 4;printf("%d",ans);return 0;
}

第005话 尼比市的决斗!

恶心模拟

良心在样例把所以情况都告诉你了。

一种方位(UDLR)对应3个情况(见样例)

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;char a[100][100];
int x,y;int main() {int n;cin >> n;for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++) {cin >> a[i][j];if (a[i][j] == 'S') {x = i; y = j;}}char c = 'D';cout << c;int cnt = 0;bool fd = a[x][y]=='T';while (!fd) {if (c=='D') {if (a[x][y+1]!='#'&&a[x+1][y+1]!='#') {if(a[x][y+1]=='T') break;x = x+1;y = y+1;c = 'L';} else if (a[x][y+1]=='#') {c = 'R';} else if (a[x][y+1] != '#') {y = y+1;}} else if (c == 'U') {if (a[x][y-1]!='#' && a[x-1][y-1] != '#') {if(a[x][y-1]=='T') break;x = x-1;y = y-1;c = 'R';}else if (a[x][y-1] == '#') {c = 'L';} else if (a[x][y-1] != '#') {y = y-1;}} else if (c == 'R') {if (a[x-1][y]!='#' && a[x-1][y+1] != '#') {if(a[x-1][y] == 'T') break;x = x-1;y = y+1;c = 'D';}else if (a[x-1][y] == '#') {c = 'U';} else if (a[x-1][y] != '#') {x = x-1;}} else if (c == 'L') {if (a[x+1][y]!='#' && a[x+1][y-1] != '#') {if(a[x+1][y] == 'T') break;x = x+1;y = y-1;c = 'U';}else if (a[x+1][y] == '#') {c = 'D';} else if (a[x+1][y] != '#') {x = x+1;}}fd |= a[x][y] == 'T';cout << c;// << x << y<<"\n";// cnt++;if(cnt == 20) return 0;}return 0;
}

第006话 皮皮和月亮石!

ok[i][j]记一下以(i,j)为左上角可不可以

删一个点最多影响附近4个,ok数组可以判重。

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;int ok[1003][1003];int main() {int n,m,q;cin >> n >> m >> q;for (int i = 1; i < n; i++)for (int j = 1; j < m; j++)ok[i][j] = 1;int sum = (n-1)*(m-1);for (int i = 1; i <= q; i++) {int x,y;cin >> x >> y;int tp = ok[x][y]+ok[x][y-1]+ok[x-1][y]+ok[x-1][y-1];ok[x][y] = ok[x][y-1] = ok[x-1][y] = ok[x-1][y-1] = 0;printf("%d\n",sum=sum-tp);}return 0;
}

第007话 华篮市的水中花!

大模拟,比赛时没做完,留坑。

第008话 通向宝可梦擂台之路!

看样例图

在左波只能降低,如果平或增加,只能落地跳到下一个右波

在右波只能增加,如果平或降低,只能通过最高点到左波

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;int a[210000];
int x,y;int main() {int n; cin >> n;for (int i = 1; i <= n; i++) cin >> a[i];bool L = 1;int ans = 0;for (int i = 2; i <= n; i++) {if (L) {if (a[i]>=a[i-1]) {ans ++;L = 0;}} else {if (a[i] <= a[i-1]) L = 1;}}printf("%d",ans);return 0;
}

Comet OJ - 2019六一欢乐赛题解相关推荐

  1. Comet OJ 2019 夏季欢乐赛题解

    Comet OJ 2019 夏季欢乐赛题解 我是来骗访问量的 A 完全k叉树 \(n\)个点的完全k叉树的直径. 直接做 B 距离产生美 直接做 C 烤面包片 \(n!!!\mod p\) 显然\(n ...

  2. Comet OJ - 2019 六一欢乐赛

    传送门 #A: 思路:等差数列求和,看成俩次1+2+-+ n,多加的n减去,所以 ans = n*(n+1) - n. AC代码: 1 #include<iostream> 2 #incl ...

  3. Comet OJ - 2019六一欢乐赛

    这个题目我先写了些简单的 之后继续填坑: 比赛链接 题目链接 题目描述 小智是一名刚满十岁的男孩,住在真新镇中,他目标是成为一名优秀的宝可梦训练师,他明天就要从大木博士那里获得自己的第一只宝可梦了.博 ...

  4. Comet OJ - 2019六一欢乐赛C.收服宝可梦吧!

    题目描述 继上一话皮卡丘把那几个坏人炸飞之后,小智确认皮卡丘已经完全恢复了.于是带着皮卡丘继续上路,前往尼比市去,小霞为了她的脚踏车的事情也一直跟着小智. 在通往尼比市的路上,要经过一个漆黑的常磐森林 ...

  5. Comet OJ - 2019六一欢乐赛D.武士少年的挑战!

    题目描述 收服绿毛虫后,小智一行继续在常磐森林里往尼比市的方向前进,小霞一路上都在大惊小怪.这时,小智发现了独角虫,他打算靠皮卡丘来收服独角虫,可是皮卡丘却懒得搭理.小霞非常讨厌虫子,远远的逃开,却碰 ...

  6. Comet OJ - 2019国庆欢乐赛(赛后整理)

    Comet OJ - 2019国庆欢乐赛(赛后整理) 比赛链接:传送门 PS: 做题失误: A题wa了好久不知道为什么,后来才知道乘法爆long long了 B题思路错了,应该在想清楚些. 比赛过程中 ...

  7. Comet OJ - 2019国庆欢乐赛 G 后缀数组

    题目链接: https://www.cometoj.com/contest/68/problem/G?problem_id=3940 出题人给的题解: 我们知道,一个子串是字符串的后缀的前缀.  这就 ...

  8. Comet OJ - 2019国庆欢乐赛 G-字符串(后缀数组)

    题目 思路来源 官方题解 题解 用大于z的字母将串分隔,值得一提,'z'+1=='{' 将询问串t1{t2{t3{tq{s接在一起 注意到最小k,即为s串内最前位置k 倒序遍历sa[]数组,更新在原串 ...

  9. 【Comet OJ - 2019国庆欢乐赛 F】 高速公路

    题意 一个长度为n的序列h[i]表示第i个位置的数不能超过h[i].每个数和相邻的数的差只能为-10,0或+10. 现在可以允许一个位置忽略限制,求数列中所有数的和最大为多少. 思路 算出没有忽略限制 ...

最新文章

  1. 第五章 Python函数你知多少
  2. mySql中使用命令行建表基本操作
  3. java元婴期(25)----java进阶(mybatis(4)---高级映射查询缓存)
  4. 华为vrrp默认优先级_华为的VRRP怎么配置
  5. wpf 语音通话_WPF+WCF一步一步打造音频聊天室(三):语音聊天
  6. Java 8中的java.util.Random
  7. 硬核总结 9 个关于认证授权的常见问题!看看自己能回答几个!
  8. 牛客国庆集训派对Day2: E. 数据排序(状压DP+记忆化搜索)
  9. 一位信息系统项目管理培训老师写的《论婚姻项目管理》值得看一下!
  10. js 获取页面高度和宽度(兼容 ie firefox chrome),获取鼠标点击位置
  11. 勒索病毒应急措施及防护方案
  12. java使用itext实现把数据库中查到的数据转换成pdf
  13. Android复制文件
  14. 总结几个有关国家行政区划的问题
  15. Ubuntu添加新的中文字体
  16. screentogif能录制声音吗_如何用Screen to Gif快速录制动图
  17. 2022 春招面试,mysql 自增主键最大值
  18. 微信的消息都要经过苹果服务器吗,为什么微信接收消息有延迟?其实是这5个原因,不知道就太可惜了...
  19. 在linux下编译运行c语言程序
  20. 看完这份987页的Java面试宝典,发现应届生求职也没那么难,面试 so easy

热门文章

  1. imssage用服务器怎么发信息,iMessage 信息如何安全发送和接收信息
  2. 李逸轩-5.31黄金还将继续下探,原油还有高点!黄金白银走势分析
  3. python课程水平测试成绩查询_学业水平考试成绩查询系统入口地址
  4. Pandas数据处理|筛选与兼职打卡时间差异在一分钟内的全职打卡数据
  5. 联通终于公布5G用户数,中国过亿5G用户仍然用着4G手机
  6. 宽屏自适应php源码,高端大气HTML5企业网站php源码自适应带后台
  7. Android开发—华为手机应用内升级之后App图标消失
  8. gradle 离线模式offline
  9. linux中df -i 100%解决方案
  10. android盒子开发招聘,[原创]Android沙盒开发之系统libc库定制修改