不知不觉4天过去了,我们迎来了我们第一次积分赛,赛前的四天我们学了以下知识点吧:

day 1、排序

之前一直想用qsort,但是总是写不明白,STL的sort()可以说是很方便了。

先写一个最基础的数组排序

bool compare(int a,int b)
{
return a<b; //升序排列,如果改为return a>b,则为降序
}#include <algorithm>
int main()
{
int a[]={,,,,,,,,,},i;
for(i=;i<;i++)
cout<<a[i]<<endl;
sort(a,a+,compare);
for(i=;i<;i++)
cout<<a[i]<<endl;
return ;
}

还有就是稍微复杂点的结构体排序

#include <iostream>
#include <vector>
#include <algorithm> using namespace std; typedef struct example
{
int elem1;
int elem2;
}example; /*这个comparison函数很重要.如果希望升序排序,就是"<",降序排列就是">"号,这样便于直观记忆.如果希望用elem2作为比较标准
就把elem1改为elem2,这样结构体就以elem2为比较标准排序了.*/ bool comparison(example a,example b){
return a.elem1<b.elem1;
} int main()
{
int N;
fin>>N; vector<example> array(N); for(int i=;i<N;i++)
{
fin>>array[i].elem1>>array[i].elem2;
} sort(array.begin(),array.end(),comparison); for(int i=;i<N;i++)
{
cout<<array[i].elem1<<" "<<array[i].elem2<<endl;
}
return ;
}

day 2、BIT冬训-模拟&枚举

模拟和枚举个人感觉算是比较简单的了,因为没有算法,所以数据范围不会很大,也不用担心TLE,但是给我印象很深的就是迷宫题和五子棋题,挺复杂的。

这里贴一个五子棋的题

Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.

In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins immediately.

Alice wins if some crosses in the field form line of length not smaller than 5. This line can be horizontal, vertical and diagonal.

Input

You are given matrix 10 × 10 (10 lines of 10 characters each) with capital Latin letters 'X' being a cross, letters 'O' being a nought and '.' being an empty cell. The number of 'X' cells is equal to the number of 'O' cells and there is at least one of each type. There is at least one empty cell.

It is guaranteed that in the current arrangement nobody has still won.

Output

Print 'YES' if it's possible for Alice to win in one turn by putting cross in some empty cell. Otherwise print 'NO'.

Example

Input
XX.XX.....
.....OOOO.
..........
..........
..........
..........
..........
..........
..........
..........
Output
YES
Input
XXOXX.....
OO.O......
..........
..........
..........
..........
..........
..........
..........
..........
Output
NO
代码如下
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
using namespace std;char mp[][];
int main()
{
for (int i = ; i < ; ++i)
{
scanf("%s",mp[i]);
} for (int i = ; i < ; ++i)
{
for (int j = ; j < ; ++j)
{
if (mp[i][j] == '.')
{
int s=;
s = ;
for (int k = j - ; k >= ; --k)
{
if (mp[i][k] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
for (int k = j + ; k < ; ++k)
{
if (mp[i][k] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
s = ;
for (int k = i - ; k >= ; --k)
{
if (mp[k][j] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
for (int k = i + ; k < ; ++k)
{
if (mp[k][j] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
s = ;
for (int k = i - , q = j - ; k >= && q >= ; --k, --q)
{
if (mp[k][q] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
} for (int k = i + , q = j + ; k < && q < ; ++k, ++q)
{
if (mp[k][q] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
s = ;
for (int k = i + , q = j - ; k < && q >= ; ++k, --q)
{
if (mp[k][q] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
// 右上
for (int k = i - , q = j + ; k >= && q < ; --k, ++q)
{
if (mp[k][q] == 'X')
{
++s;
if (s==)
{
printf("YES\n");
return ;
}
}
else break;
}
}
}
}
printf("NO\n");
return ;
}

这题的思路是看别人的,不知道贴上来算不算抄袭、

3、可以看昨天的博客

4、简单数据结构

其实今天挺复杂的,而且也是有点填鸭了,所谓的讲就是把栈,队列,堆,树这些东西怎么定义告诉了我们,并没有告诉我们有什么性质,或者有什么意义,30分钟不到讲了四个东西。我不是吐槽今天讲课的小姐姐,因为这四天都是这样,但是今天的比较困难,就有点说不过去了。不过老实说以后讲课时间会保障1个小时,看看吧。

(1)先说说栈

我也像讲课那样吧,简单的说一下用法。

#include<iostream>
#include<stack>
using namespace std; int main()
{
stack <int>stk;
//入栈
for(int i=;i<;i++){
stk.push(i);
}
cout<<"栈的大小:"<<stk.size()<<endl;
while(!stk.empty())
{
cout<<stk.top()<<endl;
stk.pop();
}
cout<<"栈的大小:"<<stk.size()<<endl;
return ;
}

(2)、C++ Queues(队列)、Priority Queues(优先队列)

C++队列是一种容器适配器,它给予程序员一种先进先出(FIFO)的数据结构。
1.back() 返回一个引用,指向最后一个元素
2.empty() 如果队列空则返回真
3.front() 返回第一个元素
4.pop() 删除第一个元素
5.push() 在末尾加入一个元素
6.size() 返回队列中元素的个数

队列可以用线性表(list)或双向队列(deque)来实现(注意vector container 不能用来实现queue,因为vector 没有成员函数pop_front!):
queue<list<int>> q1;
queue<deque<int>> q2;
其成员函数有“判空(empty)” 、“尺寸(Size)” 、“首元(front)” 、“尾元(backt)” 、“加入队列(push)” 、“弹出队列(pop)”等操作。

int main()
{
queue<int> q;
q.push();
q.push();
printf("%d\n",q.front());
q.pop();
}

C++ Priority Queues(优先队列)

C++优先队列类似队列,但是在这个数据结构中的元素按照一定的断言排列有序。
1.empty() 如果优先队列为空,则返回真
2.pop() 删除第一个元素
3.push() 加入一个元素
4.size() 返回优先队列中拥有的元素的个数
5.top() 返回优先队列中有最高优先级的元素

优先级队列可以用向量(vector)或双向队列(deque)来实现(注意list container 不能用来实现queue,因为list 的迭代器不是任意存取iterator,而pop 中用到堆排序时是要求randomaccess iterator 的!):
priority_queue<vector<int>, less<int>> pq1; // 使用递增less<int>函数对象排序
priority_queue<deque<int>, greater<int>> pq2; // 使用递减greater<int>函数对象排序
其成员函数有“判空(empty)” 、“尺寸(Size)” 、“栈顶元素(top)” 、“压栈(push)” 、“弹栈(pop)”等。

 #include <iostream>
#include <queue>
using namespace std; class T {
public:
int x, y, z;
T(int a, int b, int c):x(a), y(b), z(c)
{
}
};
bool operator < (const T &t1, const T &t2)
{
return t1.z < t2.z; // 按照z的顺序来决定t1和t2的顺序
}
main()
{
priority_queue<T> q;
q.push(T(,,));
q.push(T(,,));
q.push(T(,,));
q.push(T(,,));
while (!q.empty())
{
T t = q.top();
q.pop();
cout << t.x << " " << t.y << " " << t.z << endl;
}
return ;
}

输出结果为(注意是按照z的顺序从大到小出队的): 
      3 3 6 
      2 2 5 
      1 5 4 
      4 4 3

 #include <iostream>
#include <queue>
using namespace std;
class T
{
public:
int x, y, z;
T(int a, int b, int c):x(a), y(b), z(c)
{
}
};
bool operator > (const T &t1, const T &t2)
{
return t1.z > t2.z;
}
main()
{
priority_queue<T, vector<T>, greater<T> > q;
q.push(T(,,));
q.push(T(,,));
q.push(T(,,));
q.push(T(,,));
while (!q.empty())
{
T t = q.top();
q.pop();
cout << t.x << " " << t.y << " " << t.z << endl;
}
return ;
}

输出结果为: 
      4 4 3 
      1 5 4 
      2 2 5 
      3 3 6
      如果我们把第一个例子中的比较运算符重载为: bool operator < (const T &t1, const T &t2) { return t1.z > t2.z; // 按照z的顺序来决定t1和t2的顺序} 则第一个例子的程序会得到和第二个例子的程序相同的输出结果。

目前主要学的就这么多了,感觉题目已经很难很难了。

以上均为不规范转载。。。因为我还没有完全掌握。

ACM集训第一次积分赛赛前复习+day4的更多相关文章

  1. 2018.10.19浪在ACM 集训队第一次测试赛

    2018.10.19浪在ACM 集训队第一次测试赛 待参考资料: [1]:https://blog.csdn.net/XLno_name/article/details/78559973?utm_so ...

  2. yzm10的ACM集训小感

    7月30号,ACM集训进行了两周,一切都已on the right way.这时的我适时地从题海中探出头,其实除了刷题,也该写点什么来总结下过去.首先,在第一周里,我学习了数据结构,知道了STL这么一 ...

  3. 【系列】关于NJUPT电赛自控方向第一次积分赛的总结

    本人是NJUPT电子科学与技术专业大一摸鱼狗一枚.本博客旨在总结与分享个人准备电赛所学知识,同时也是为了防止遗忘,锻炼写文章的能力.目前电赛方向为自控方向.主要研究方向为单片机.图像处理.自动控制相关 ...

  4. ACM集训

    2019-07-18 09:06:10 emmm.... 昨天5个小时做了一道题,心情复杂,不着急慢慢来 Ivan recently bought a detective book. The book ...

  5. ACM集训的Day3 B。。。盲目搜索之DFS。。。

    milk 一.题目描述: gzp有三个容量分别是A,B,C升的桶,A,B,C分别是三个从1到20的整数, 最初,A和B桶都是空的,而C桶是装满牛奶的.有时,农民把牛奶从一个桶倒到 另一个桶中,直到被灌 ...

  6. ACM集训的1B。。。。黑色星期五。。。。2333333

    题目: 印象中有好多个13号是星期五,13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900 ...

  7. ACM集训的Training Day 3的A题。。。

    A. 等差数列 一.题目描述: 一个等差数列是一个能表示成a, a+b, a+2b,..., a+nb (n=0,1,2,3,...)的数列. 在这个问题中a是一个非负的整数,b是正整数.写一个程序来 ...

  8. ACM集训的第。。。诶~不知道第几题=.=

    题目: 郭铮鹏认为排序是一种很频繁的计算任务,所以他考虑了一个简单的问题:现在最多只有三值的排序问题.一个实际的例子是,当我们给某项竞赛的优胜者按金银铜牌排序的时候.在这个任务中可能的值只有三种1,2 ...

  9. ACM集训的第一题

    对于一群NP(2<=NP<=10)个要互送礼物的朋友,郭铮鹏要确定每个人送出的钱比收到的多多少. 在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人 ...

随机推荐

  1. 微服务迁移记(五):WEB层搭建(2)-SpringSecurity集成

    一.redis搭建 二.WEB层主要依赖包 三.FeignClient通用接口 以上三项,参考<微服务迁移记(五):WEB层搭建(1)> 接下来,集成SpringSecruity,实现用户 ...

  2. Webpack 原理浅析

    作者: 凹凸曼 - 风魔小次郎 背景 Webpack 迭代到4.x版本后,其源码已经十分庞大,对各种开发场景进行了高度抽象,阅读成本也愈发昂贵.但是为了了解其内部的工作原理,让我们尝试从一个最简单的 ...

  3. Struts2中Get请求转码问题

    Tomcat默认编码为ISO859-1 Post提交时,struts2会对其转码为iso8859-1,因此不需要另外转码,而 Get提交表单,则需要单独转码,转码过程如下图:

  4. 为什么 2020 还要学 Node.js

    更佳阅读体验 https://www.yuque.com/sunluyong/node 前言 前些日子刷知乎看到个 2019 年初的问题 2019年nodejs凉了吗?凉到什么程度了?才看到问题的时候 ...

  5. 使用hibernate validate做参数校验

    1.为什么使用hibernate validate ​ 在开发http接口的时候,参数校验是必须有的一个环节,当参数校验较少的时候,一般是直接按照校验条件做校验,校验不通过,返回错误信息.比如以下校验 ...

  6. 用 Python 了解一下最炫国漫《雾山五行》

    看动漫的小伙伴应该知道最近出了一部神漫<雾山五行>,其以极具特色的水墨画风和超燃的打斗场面广受好评,首集播出不到 24 小时登顶 B 站热搜第一,豆瓣开分 9.5,火爆程度可见一斑,就打斗 ...

  7. 密码学系列——常见的加密方式(c#代码实操)

    前言 说起加密方式,其实密码学的角度ASCII编码其实本身就是一种加密解密. 由于其公开,现在用于数字与字符的转换. 查看ASCII表可以去官网查查. 转换代码如下: static void Main ...

  8. U盘数据泄露,用不到30行的Python代码就能盗走

    今天跟大家分享下一段简单的代码,希望能给经常用U盘的人警戒,提高信息安全意识. 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法过后,不知道在哪里寻找案例上手.很多已经做 ...

  9. SpringCloud微服务:基于Nacos组件,整合Dubbo框架

    源码地址:GitHub·点这里 || GitEE·点这里 一.基础组件简介 1.Dubbo框架 Dubbo服务化治理的核心框架,之前几年在国内被广泛使用,后续由于微服务的架构的崛起,更多的公司转向微服 ...

  10. 节点操作 - DOM编程

    1. 获取节点 1.1 直接获取节点 父子关系: element.parentNode element.firstChild/element.lastChild element.firstElemen ...