7.18模考总结

7.18 星期一 晴/雷

模考总结

T1

纯水题,开局 10 分钟直接 AC, 二分板子题,普及难度。
AC code:
#pragma (3, "OFast", "inline")
#pragma (2)
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <climits>
#include <random>
#include <bitset>
#include <unordered_map>
#define int long long
#define orz %
#define ll long long
#define juruo Optimist_Skm
#define mid ((l + r) >> 1)
#define pii std::pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define m_p std::make_pair
#define pq std::priority_queue<int>
#define pq_min std::priority_queue<int, std::vector<int>, std::greater<int> >
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define test(x) cout << "Test: " << x << '\n'
#define close fclose(stdin);fclose(stdout);

namespace Fast_Skm {

	template <typename T>
	inline void read(T &x) {
		register int s = 0, w = 1;
 		char c = getchar();
		while(!isdigit(c)) {
			if(c == '-')  w  = -1;
			c = getchar();
		}
		while(isdigit(c))
			s = (s << 1) + (s << 3) + (c & 0xcf), c = getchar();
			
		x = s * w;
		return ;
	}

	template <typename T, typename... Arp>
	inline void read(T &x, Arp &...arp) {
		read(x), read(arp...);
        return ;
	}

	template <typename T>
	inline void write(T x) {
		if(x < 0) x = -x, putchar('-');
		register int p = 0;
		static char s[100];
		do {
			s[++p] = x orz 10 + '0';
			x /= 10;
		} while (x);
		while(p) putchar(s[p--]);
		putchar('\n');
	}

	template <typename T, typename... Arp>
	inline void write(T &x, Arp &...arp) {
		write(x), write(arp...);
		return ;
	}

	template <typename S, typename T>
	inline void smax(S &x, T y) {
		x = (x > y) ? x : y;
	}

	template <typename S, typename T>
	inline void smin(S &x, T y) {
		x = (x < y) ? x : y;
	}

	inline void quit() {
		exit(0);
		return ;
	}
	
	inline ll quick_pow(ll a, ll b, ll P) {
		register ll ans = 1;
		while(b >= 1) {
			if(b & 1) {
				ans = ans * a % P;
			}
			a = a * a % P;
			b >>= 1;
		}
		return ans;
	}

} using namespace Fast_Skm;

const int N = 1e5 + 7;
const ll M = 1e15;
ll n, m, a[N], x[N];

inline bool check (ll y) {
	ll cnt = 0;
	for (int i = 1; i <= n; ++i) {
		cnt += (a[i] + y - 1) / y;
		if (cnt > m | cnt < 0) {
			return 0;
		}
		cnt += x[i];
		if (cnt > m || cnt < 0) {
			return 0;
		}
	}
	return cnt <= m;
}

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	//freopen("1.out", "r", stdin);

	read(n, m);

	bool f = 0;
	for (int i = 1; i <= n; ++i) {
		read(a[i], x[i]);
		if (x[i] > m) {
			f = 1;
		}
	}

	if (f || n > m) {
		write(-1);
        return 0;
	}

	int l = 1, r = M + 1, best = -1;
	while (l <= r) {
		if (check(mid)) {
			best = mid;
			r = mid - 1;

		}
		else {
			l = mid + 1;
		}
	}

	write(best);

	return 0;
}

T2

数学题, 推出公式套用即可 (可惜考试推的时候把求积符号也一起带了进去,推了一个半小时也没推出来
总结:当一个整体推不出的时候,就要学会以小见大,从小事做起,从小的块推向大的块,有特殊到普遍。
订正代码:
#pragma (3, "OFast", "inline")
#pragma (2)
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <climits>
#include <random>
#include <bitset>
#include <unordered_map>
#define int long long
#define orz %
#define ll long long
#define juruo Optimist_Skm
#define mid ((l + r) >> 1)
#define pii std::pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define m_p std::make_pair
#define pq std::priority_queue<int>
#define pq_min std::priority_queue<int, std::vector<int>, std::greater<int> >
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define test(x) cout << "Test: " << x << '\n'
#define close fclose(stdin);fclose(stdout);
#define ull unsigned long long

namespace Fast_Skm {

	template <typename T>
	inline void read(T &x) {
		register int s = 0, w = 1;
 		char c = getchar();
		while(!isdigit(c)) {
			if(c == '-')  w  = -1;
			c = getchar();
		}
		while(isdigit(c))
			s = (s << 1) + (s << 3) + (c & 0xcf), c = getchar();
			
		x = s * w;
		return ;
	}

	template <typename T, typename... Arp>
	inline void read(T &x, Arp &...arp) {
		read(x), read(arp...);
        return ;
	}

	template <typename T>
	inline void write(T x) {
		if(x < 0) x = -x, putchar('-');
		register int p = 0;
		static char s[100];
		do {
			s[++p] = x orz 10 + '0';
			x /= 10;
		} while (x);
		while(p) putchar(s[p--]);
		putchar(' ');
	}

	template <typename T, typename... Arp>
	inline void write(T &x, Arp &...arp) {
		write(x), write(arp...);
		return ;
	}

	template <typename S, typename T>
	inline void smax(S &x, T y) {
		x = (x > y) ? x : y;
	}

	template <typename S, typename T>
	inline void smin(S &x, T y) {
		x = (x < y) ? x : y;
	}

	inline void quit() {
		exit(0);
		return ;
	}
	
	inline ll quick_pow(ll a, ll b, ll P) {
		register ll ans = 1;
		while(b >= 1) {
			if(b & 1) {
				ans = ans * a % P;
			}
			a = a * a % P;
			b >>= 1;
		}
		return ans;
	}
	
	template <typename T>
	inline T exgcd(T a, T b, T &x, T &y) {
		if(b == 0) {
		 	x = 1; y = 0;
		 	return a;
		}
		int gcd = exgcd(b, a % b, x, y);
		int tmp = y;
		y = x - a / b * y;
		x = tmp;
		return gcd;
	}


} using namespace Fast_Skm;

const int N = 5e5 + 7;
int n, a[N], b[N];

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	read(n);

	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}

	for (int i = 1; i <= n; ++i) {
		read(b[i]);
	}

	for (int i = 2; i <= n; ++i) {
		ull x, y;
		x = a[i - 1] * a[i] + b[i - 1] * b[i];
		y = a[i - 1] * b[i] - b[i - 1] * a[i];
		a[i] = x;
		b[i] = y; 
	}

	write(a[n], b[n]);

	return 0;
}

T3

字符串,KMP,没学过的知识点,看完题目后没发现有暴力分,直接放弃。
总结:补全自己的知识面,加强代码能力。

T4

看似是树剖,实际上是线段树的区间操作,题面较复杂,不易理解,考试时的暴力预计得分30,实际得分0。
总结:加强对每一个算法底层逻辑与思想的理解,减少出现将一个算法与另一个算法混淆的情况。加强代码能力,提高暴力的正确率。

附:随笔:

这次比赛使我深刻地认识到了我的薄弱面,并明确了我的训练目标,同时,也让我看到了自己努力的成果,给予了我继续在OI之路上披荆斩棘的勇气与动力。 李白曾言道:“乘风破浪会有时,直挂云帆济沧海”,在茫茫人海中,我们是如此的弱小,在强大的人面前,我们是如此的无力,然而,“苔花如米小,也学牡丹开”,即使弱小,也要有“轻肌弱骨散幽葩,更将金蕊泛流霞。”的觉悟与情怀。

“仁者见仁,智者见智” 成为优秀的人,看到的世界是不一样的,每当你登上一座新的山峰,都会享受那里细腻清风的洗涤,与明媚阳光的沐浴。与其在山脚说山顶是令人心驰神往的,不如立刻付诸行动。

人们常说“高处不胜寒”,实则不然,人们在高处,往往会看见自己的努力,回顾自己一步一步网上爬的历程——我认为,高处,是最吸引人的。高处,是神秘的,是优雅的,是神圣的,所有人的目标都将是高处,然则,我们就更应努力地奔跑,永不停下。

余秋雨在《文化苦旅》中说道,“繁华转眼凋零,喧嚣是短命的别名”,我们不能在拥有一点知识后就自我满意,“水满则溢,月满则亏,自满则败,自矜则愚”,我们要保持虚心的心态与视角,不耻下问,同时,向高处攀登。

一个跑者,在一场马拉松中,是不会停下的,因为一旦停下,就很难再重新跑起来。在一眼望不到边的OI赛道上,我们或快,或慢,或前,或后,但这些都不重要,从现在起,不要停下,一直跑下去吧。

综上所述,努力吧,OIer!

“可不要辜负自己的努力啊,2024还有机会在等着我呢!” ——Syx

posted @ 2024-07-18 18:52  Optimist_Skm  阅读(38)  评论(1)    收藏  举报