首页 > 其他分享 >模拟赛总结(1)

模拟赛总结(1)

时间:2023-08-03 15:56:58浏览次数:23  
标签:总结 10 ch int ll write include 模拟

一.题目解析

1.遗忘的来年花期

20%:

因为序列严格递增,所以直接 cout << 0; 即可。

100%:

注意不等号和 \(i\) 的范围,之后直接模拟。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=1e3+10, maxn=1e6+100;
template <typename T> inline void read(T &x) {
	x = 0;
	bool flag = false;
	char ch = getchar();
	while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
	if(flag) x = -x;
}
template <typename T> inline void write(T x) {
	if(x<0) {
		putchar('-');
		x = -x;
	}
	if(x>9) write(x / 10);
	putchar(x % 10 + '0');
}
ll n, a[maxn]; 
ll cnt;
int main() {
//	freopen("flower.in", "r", stdin);
//	freopen("flower.out", "w", stdout);
    read(n);
    for (int i = 1;i <= n; ++i) {
    	read(a[i]);
	}
	for (int i = 2;i < n; ++i) {
    	if(a[i] >= a[i-1] && a[i] >= a[i+1]) {
    		cnt++;
		}
	}
	write(cnt);
	printf("\n");
	return 0;
}

2.意外爱上黄昏来临时

20%:

\(n=2\) 的数据范围,所以直接枚举 \(k\) 即可。

80%:

由于 \(y\) 可以被 \(x\) 用桶记录,所以不用枚举 \(y\)。

100%:

用字符串维护每一列的 \(01\) 数(也可以说成二进制转换),用一个 unordered_map 就行。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=1e3+10, maxn=1e6+10;
template <typename T> inline void read(T &x) {
	x = 0;
	bool flag = false;
	char ch = getchar();
	while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
	if(flag) x = -x;
}
template <typename T> inline void write(T x) {
	if(x<0) {
		putchar('-');
		x = -x;
	}
	if(x>9) write(x / 10);
	putchar(x % 10 + '0');
}
int n, m, a[1005][1005];
unordered_map<string, vector <int> > mp;
int main() {
    read(n), read(m);
	string s;
	s.resize(m);
	for (int i = 1;i <= m; i++)
		for (int j = 1;j <= n; j++)
			cin >> a[i][j];
	for (int i = 1;i <= n; i++) {
		for (int j = 1;j <= m; j++) s[j-1] = a[j][i];
		mp[s].push_back(i);
	}
	pair<int, int> p = make_pair(n+1, n+1);
	for(auto &it : mp)
		if(it.second.size() >= 2)
			p = min(p, make_pair(it.second[0], it.second[1]));
	if(p.first == n+1) puts("-1");
	else printf("%d %d", p.first, p.second);
	return 0;
}

3.星空分崩离析

目前只会暴力做法

20%:

预处理每个点的 \(dis(1, u)\) 和每对点的 \(dis(u, v)\),处理完排序。
然后暴力枚举满足 \(dis(1, u) > x\) 的所有对,统计 \(dis\)。

4.死在二十四岁的自己

100%:

一看题和数据范围,发现是推式子的题,合并了一下题目中的式子,发现每个数都有一个贡献公式:max(x) - a[i] - 1
之后直接加一遍就行了。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=1e3+10, maxn=1e6+10;
template <typename T> inline void read(T &x) {
	x = 0;
	bool flag = false;
	char ch = getchar();
	while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
	if(flag) x = -x;
}
template <typename T> inline void write(T x) {
	if(x<0) {
		putchar('-');
		x = -x;
	}
	if(x>9) write(x / 10);
	putchar(x % 10 + '0');
}
ll n, a[maxn];
ll cnt;
ll sum;
int main() { 
    //freopen("resurrection.in", "r", stdin);
	//freopen("resurrection.out", "w", stdout);
    read(n);
    for (int i = 1;i <= n; ++i) {
    	read(a[i]);
	}
    sort(a+1,a+n+1);
    if (n == 1) {
		write(0);
		printf("\n");
		return 0;
	}
	else if (n == 2) {
		cnt = a[2] * 2 - (a[1] + a[2]) - 2;
		if (cnt > 0) {
			write(cnt);
			printf("\n");
		}
		else {
			write(0);
			printf("\n");
		}
	}
	else {
		for (int i = 1;i <= n; ++i) {
    		sum += a[i];
		}
		cnt = a[n] * n - sum - n; 
		if (cnt > 0) {
			write(cnt);
			printf("\n");
		}
		else {
			write(0);
			printf("\n");
		}
	}
	return 0;
}

这个题的数据多少有点问题,所有数都取到就 \(100\) 了。

二.总结

这次考的还行,主要是考场上灵光乍现想出 \(T2\) 和 \(T4\) 的正解,\(T3\) 出了个树上模拟挺意外的,多刷一些关于树的题。

标签:总结,10,ch,int,ll,write,include,模拟
From: https://www.cnblogs.com/abc-mx/p/17603545.html

相关文章

  • web前端技能方法总结(css、js、jquery、html)(2)
    创建链接块display:block;列表样式在一个无序列表中,列表项的标志(marker)是出现在各列表项旁边的圆点。在有序列表中,标志可能是字母、数字或另外某种计数体系中的一个符号。要修改用于列表项的标志类型,可以使用属性list-style-type:ul{list-style-type:square;}1上面的声明把......
  • 【考后总结】8 月 CSP-S 模拟赛 1
    8.3CSP模拟13\(\text{zero4338round}\)T1y显然\(\text{xt}\)会选择四个角,对每个格子求出到四个角的曼哈顿距离最大值,操作一定会优先选择最大值较小的,所以把距离数组排个序就行了。T2s经典套路是设答案是\(a\),把小于\(a\)的位置设成\(0\),大于等于设成\(1\),这样按......
  • Tita 升级|总结模板,满足多种管理要求
    升级详情一、【总结】支持自定义总结模板「总结模板」菜单1.都谁可见总结管理员、超管、老板、助理可见总结模板菜单,并可查看系统模板与公司的所有自定义模板;当你被授权为某个自定义菜单的管理员时,也可看到总结模板菜单与被授权管理的模板;注意:系统模板不可编辑,仅总结管......
  • 微信小程序页面跳转方法总结
    在我们日常的开发过程中,跳转页面是每个项目中必有的需求,包括监听返回按钮,回到指定页面,在小程序中页面跳转即页面路由页面栈框架以栈的形式维护了当前的所有页面。当发生路由切换的时候,页面栈的表现如下:getCurrentPages()函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,第一......
  • 嵌入式软件开发就业面试题。2022最新,最全总结
    1.select和epoll的区别解题思路(这个我在找面试题之前没了解过,还是学的太少了,多学!!!)select的时间复杂度O(n)。它仅仅知道了,有I/O事件发生了,却并不知道是哪那几个流(可能有一个,多个,甚至全部),我们只能无差别轮询所有流,找出能读出数据,或者写入数据的流,对他们进行操作。所以select具有O......
  • 做每日总结的重要性
    每日总结是一种对自己工作和学习的反思和总结,具有重要的意义和作用。以下是每日总结的重要性:1.提高工作效率:每日总结可以帮助我们回顾一天的工作,发现工作中存在的问题和不足之处,并提出改进的方法和措施。通过总结,我们可以更好地规划和安排下一天的工作,提高工作的效率和质量。2......
  • 【Java】多线程面试题总结
    最近在看面试题,所以想用自己的理解总结一下,便于加深印象。为什么使用多线程使用多线程可以充分利用CPU,提高CPU的使用率。提高系统的运行效率,对于一些复杂或者耗时的功能,可以对其进行拆分,比如将某个任务拆分了A、B、C三个子任务,如果子任务之间没有依赖关系,那么就可以使用多线程......
  • leetcode练习过的题目总结
    1.leetcode主要选项是:栈+双指针题号难度:简单链接20有效的括号26删除排序数组中的重复项27移除元素28实现strStr()88合并两个有序数组125.验证回文串141环形链表167两数之和II-输入有序数组225用队列实现栈232用栈实现队列234回文链表283移动零344反转字符串345反转字符串中的元......
  • C和C++进阶的学习笔记总结目录
    C语言–C语言基础知识积累记录学习教程:参考C++教程网之跟我一起学Cdo{…}while(0)的用途汇总(欢迎补充)在一些Linux内核和其它的开源代码中可见到【C语言】《带你学C带你飞》,笔记:链接––C++–一张图总结GoogleC++编程规范(GoogleC++StyleGuide)C++基础学习目录总结参考:链......
  • 校际交流模拟总结(updating)
    前言由于上次补总结补了一整天多,决定每天及时写总结。校际交流,但是被本校的人吊打。Day1总体情况都是CF6月24日Div1+Div2的原题,早知道多打点CF了。T1考场降智没想出来,后面暴力基本上都打了。60+20+50+20=150,rk3怎么一回家就会T1了啊!T1CF1842C一眼DP,只会\(......