2021 CCPC女生赛
newbie,A了五题铜牌收工
比赛时和队友悠哉游哉做题,想着干饭,最后幸好没滚出铜尾。
贴一下比赛过的代码
A题 签到
队友A的,判断正反方向序列是否符合要求
/***
* @Author: _Krill
* @Date: 2021-10-31 09:00:34
* @LastEditTime: 2021-10-31 09:54:36
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int station[10];
int bussta[10];
int n,x,y,m;
int func(){
bool flag1=true;
bool flag2=true;
for(int i=x+1,j=1;i<=x+m;i++,j++){
if(bussta[j]!=station[i]){
flag1=false;
break;
}
}
for(int i=x-1,j=1;i>=x-m;i--,j++){
if(bussta[j]!=station[i]){
flag2=false;
break;
}
}
if(flag1&&flag2){
return 0;
}
else if(flag1&&!flag2)
return 1;
else
return -1;
}
int main()
{
// IO_fast
cin>>n>>x>>y;
for(int i=1;i<=n;i++){
cin>>station[i];
}
cin>>m;
if(m>abs(x-y)){
cout<<"Wrong"<<endl;
return 0;
}
for (int i = 1; i <= m; i++)
{
cin>>bussta[i];
}
int fu=func();
if(fu==0)
cout<<"Unsure"<<endl;
else if(fu==1){
if(x>y)
cout<<"Wrong"<<endl;
else
cout<<"Right"<<endl;
}
else{
if(x>y)
cout<<"Right"<<endl;
else{
cout<<"Wrong"<<endl;
}
}
return 0;
}
D题
刚看以为是最小生成树,实际上毫无关系。
把所有村庄按费用从大到小排序,依次检查是不是边界,是边界就加两次,否则加一次。
/***
* @Author: _Krill
* @Date: 2021-10-31 09:13:24
* @LastEditTime: 2021-10-31 09:54:45
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
struct node {
int num, e;
};
node arr[200005];
bool cmp(const node& a, const node& b) {
return a.num > b.num;
}
int vis[200005];
int main()
{
IO_fast
int n;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> arr[i].num;
arr[i].e = i + 1;
}
ll sum = 0;
int cnt = 0;
sort(arr, arr + n, cmp);
for(int i = 0; i < n && cnt < n; i++ ) {
vis[arr[i].e] = 1;
if(arr[i].e - 1 >= 1) {
if(!vis[arr[i].e - 1]) {
sum += arr[i].num;
cnt++;
}
}
if(arr[i].e + 1 <= n) {
if(!vis[arr[i].e + 1]) {
sum += arr[i].num;
cnt++;
}
}
}
cout << sum << '\n';
return 0;
}
G题 签到
队友A的,求 1 / n
/***
* @Author: _Krill
* @Date: 2021-10-31 10:08:07
* @LastEditTime: 2021-10-31 10:17:15
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int x,y;
cin>>x>>y;
}
double ans;
ans=1.0/n;
printf("%16f",ans)
}
I题 模拟题
debug了好久,恰好饭点,也就饭后甜点解决了~
开始队友提供思路左转右转45度就是三角函数的变化,but脑子短路,也没写对。
最后是用dx,dy方向数组,+1表示右转,-1表示左转,开始是向前的,状态为 (-1, 0)。
/***
* @Author: _Krill
* @Date: 2021-10-31 10:05:05
* @LastEditTime: 2021-10-31 12:48:36
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef pair<int, int> pp;
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int n, m;
char arr[55][55];
int curV = 0;
int dire = 0;
bool judge(int xx, int yy) {
if(dx[dire] != 0 && dy[dire] != 0) {
int t1 = (dire - 1 + 8) % 8, t2 = (dire + 1) % 8;
if(arr[xx + dx[t1]][yy + dy[t1]] == '#' && arr[xx + dx[t2]][yy + dy[t2]] == '#') return false;
}
return true;
}
pp move(pp st) {
int xx = st.first, yy = st.second;
for(int i = 0; i < curV; i++) {
xx += dx[dire], yy += dy[dire];
if(xx <= 0 || xx > n || yy <= 0 || yy > m || arr[xx][yy] == '#' || !judge(st.first, st.second)) {
cout << "Crash! ";
curV = 0;
return st;
}
st = pp(xx, yy);
}
return st;
}
int main()
{
int q;
pp st;
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> arr[i][j];
if(arr[i][j] == '*') {
st = pp(i, j);
arr[i][j] = '.';
}
}
}
string op;
cin >> q >> op;
for(int i = 0; i < q; i++) {
if(op[i] == 'L') {
dire = (dire - 1 + 8) % 8;
}
else if(op[i] == 'R') {
dire = (dire + 1) % 8;
}
else if(op[i] == 'U') {
curV += 1;
}
else {
curV = max(curV - 1, 0);
}
st = move(st);
cout << st.first << ' ' << st.second << '\n';
}
return 0;
}
K题 统计 '-' 的个数,签到。
/***
* @Author: _Krill
* @Date: 2021-10-31 09:02:15
* @LastEditTime: 2021-10-31 18:06:19
*/
#include<bits/stdc++.h>
using namespace std;
#define IO_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int main()
{
IO_fast
int n;
cin >> n;
int cnt = 0;
char ch;
while(cin >> ch) {
if(ch == '-') cnt++;
}
cout << cnt << '\n';
return 0;
}
之后还开了 B 题和 C 题,B 题题目意思真难懂,猜了一下没通过样例,时间还剩半个小时,队友建议转向 C 题。C 题数据范围很小,想了下用 DFS 回溯,刚写的时候毒奶自己每次写回溯都会有 bug,果不其然,到最后两分钟,样例还是没过,随终。
队里都没时间准备,所以拿到铜还是挺满意的,如果做题时没那么悠哉闲聊,感觉还是可以把 C 调出来
补题了
2021 CCPC女生赛的更多相关文章
- 2019.ccpc女生赛-wfinal总结
2019ccpc女生赛离它结束有四天了,在这个期间我想了很多,想了想还是决定写这个总结.作为这个队伍唯一的一名大一队员,我很庆幸,能跟着两个学姐一起打比赛,计爱玲师姐,即将工作,张莹俐学姐.这估计都是 ...
- 2018 CCPC 女生赛 hdoj6287 口算训练
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6287 Summarize: 1.分解质因数: 2.二分查找函数lower_bound与upper_bo ...
- 2018 CCPC 女生赛 hdoj6288 缺失的数据范围
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6288 Summarize:1.二分查找答案: 2.自带log函数精度不够,需自己写: 3.注意二分递归 ...
- 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree
// 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...
- (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...
- 2018 CCPC网络赛
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...
- ccpc 网络赛 hdu 6155
# ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...
- # 江西ccpc省赛-waves-(DP做法)
江西ccpc省赛-waves-(DP做法) 题链:http://acm.hdu.edu.cn/showproblem.php?pid=6570 题意:给你长度为N,1≤N≤100000的一个数组,其中 ...
- # 江西CCPC省赛-Rng(概率+逆元)
江西CCPC省赛-Rng(概率+逆元) 题意: 给出一个n,在[1,n]之间选一个R1,在[1,R1]之间选一个L1,得到区间[L1,R1],同理获取区间[L2,R2],问两个区间相交的概率对1e9+ ...
随机推荐
- 羽夏看Win系统内核——环境搭建
写在前面 此系列是本人一个字一个字码出来的,包括示例和实验截图.由于系统内核的复杂性,故可能有错误或者不全面的地方,如有错误,欢迎批评指正,本教程将会长期更新. 如有好的建议,欢迎反馈.码字不易, ...
- 10.6Java学习
1.类,对象,方法的定义.2.标识符分为两类:关键字/常见的基本类型:boolean(布尔型),byte(字节型),char(字符型),double(双精度),float(浮点),int(整型),lo ...
- python面向对象(封装,继承,多态)
python面向对象(封装,继承,多态) 学习完本篇,你将会深入掌握 如何封装一个优雅的借口 python是如何实现继承 python的多态 封装 含义: 1.把对象的属性和方法结合成一个独立的单位, ...
- 【PHP数据结构】栈的相关逻辑操作
对于逻辑结构来说,我们也是从最简单的开始.堆栈.队列,这两个词对于大部分人都不会陌生,但是,堆和栈其实是两个东西.在面试的时候千万不要被面试官绕晕了.堆是一种树结构,或者说是完全二叉树的结构.而今天, ...
- win7任务计划提示”该任务映像已损坏或已篡改“
打开任务计划,弹出了下面的对话框[该任务映像已损坏或已篡改.(异常来自HRESULT:0x80041321)] 首先你以管理员的身份运行cmd命令,打开运行窗口 输入:chcp 437,并回车,回车后 ...
- Sentry 监控 - Search 搜索查询实战
系列 1 分钟快速使用 Docker 上手最新版 Sentry-CLI - 创建版本 快速使用 Docker 上手 Sentry-CLI - 30 秒上手 Source Maps Sentry For ...
- P1074 [NOIP2009 提高组] 靶形数独
#include<bits/stdc++.h> using namespace std; const int N=10; int a[N][N],ans[N][N],vis[3][N][N ...
- css 参考手册 部署到本地
* 到css参考手册网站 http://css.doyoe.com/ 下载chm手册 * 到github下载对应的html页面 cd /Applications/XAMPP/htdocs git cl ...
- $.ajax 常用的套路
$.ajax 常用的套路 (function(){ window.webApi = new Object(); webApi.get = function(url,data,callback){ $. ...
- django错误处理
1.django.db.utils.OperationalError: no such table 意思:没有这个app应用对应的数据表的,可以用 python manage.py makemigra ...