不知不觉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. Python os.stat() 方法

    概述 os.stat() 方法用于在给定的路径上执行一个系统 stat 的调用.高佣联盟 www.cgewang.com 语法 stat()方法语法格式如下: os.stat(path) 参数 pat ...

  2. Python File writelines() 方法

    概述 writelines() 方法用于向文件中写入一序列的字符串.高佣联盟 www.cgewang.com 这一序列字符串可以是由迭代对象产生的,如一个字符串列表. 换行需要制定换行符 \n. 语法 ...

  3. PHP tmpfile() 函数

    定义和用法 tmpfile() 函数以读写(w+)模式创建一个具有唯一文件名的临时文件. 语法 tmpfile() 提示和注释 注释:临时文件会在文件关闭后(用 fclose())或当脚本结束后自动被 ...

  4. PHP chunk_split() 函数

    实例 在每个字符后分割一次字符串,并在每个分割后添加 ".": <?php$str = "Hello world!";高佣联盟 www.cgewang.c ...

  5. Skill 导出所有Layer信息用于tapeout

    https://www.cnblogs.com/yeungchie/ 用于在 tapeout 前要走的流程,foundry 会需要你上传一份芯片用到的所有 Layer 的 excel 文档. TAB ...

  6. DB_LINK删除

    由于业务需求,对测试库数据进行模糊化.为保生产数据安全,先删db_link; 1.共有db_link删除: select 'drop public database link '||db_link|| ...

  7. c++ explict

    explicit 用于一个参数的构造函数:防止隐式转换. 什么意思呢? myClass(int x); 这是个构造函数 我们可以使用 myClass a(4);  或 myClass a=4;来调用它 ...

  8. 【HEOI2015】公约数数列 题解(分块)

    前言:毒瘤数据结构题,半个下午都在搞它了…… --------------------------- 题目链接 题目大意:给定一个长度为$n$的序列,有两种操作:1.把$a_x$的值改成$y$.2.求 ...

  9. 微信小程序后台springboot+mybatis+mysql“采坑”集锦

    "采坑"错误集锦 1.service层 错误描述:2019-04-14 22:09:52.027 ERROR 8416 --- [nio-8082-exec-5] o.a.c.c. ...

  10. ASP.NET Core3.x 基础(1)

    ASP.NET Core与2.x相比发生的一些变化: 项目结构 Blazor SignalR gRPC 关于Program类:Main方法,在系统执行时就会找到这个Main方法,实际上是配置了ASP. ...