2022.9.10———Luogu月赛【【LGR-119】洛谷 9 月月赛 I & Wdoi2022 R2 Div.2 】乱搞记

\(Write\ In\ Front\)

首先祝老师们节日快乐qwq

不是,主要是脑子有点混乱不知道该干啥所以来水博客(

$Rank312/2239 $

一共水到了\(260pts\)

我菜菜

主要是这里边有人去灌水挂比赛刷咕?本校高二排名 \(Rank二十多/43\)

我还是菜菜

话说\(Luogu\)好多車万众

\[ \Huge \mathbf{注:本篇博文写的基本都是部分分得法}(虽然叨的根本不详细) \]

\(\mathfrak{T1}\ 花如幻想一般\)

签到题一个 来了十几分钟两发\(A\)

主要就是 我直接猜他顶多只会翻转一次,然后分别统计翻转和不翻转的时候达到目标状态需要多少次,取最小值就完了

T1
#include <iostream>
#define GMY (520&1314)
#define FBI_OPENTHEDOOR(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define re register int
#define char_phi signed
#define MARK cout << "###"
#define MARKER "@@@"
#define LMARK "!!!~~~"
#define ZY " qwq "
#define _ ' '
#define Endl cout << '\n'
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define N 500005
using namespace std;
inline void Fastio_setup(){ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);}
/*
	故垒西边,人道是
	"这题我不会啊?"
	首先我觉得如果需要翻转的话顶多需要翻转一次
	定义一种"达到目标的差值",也就是到达还原完毕所需要的次数
	在最开始阶段算一下原序列差值和翻转一下后序列的差值
	如果当前翻转一下更优的话就翻一下
	否则就直接按原序列去搞就完了
	然后对于目前得到的perfect序列直接判断每个位置是否需要+-数 有的话操作次数+1
	然后记得如果perfect序列是翻转来的记得ans+1
	怎么觉得不靠谱呢。。
	应该不需要开longlong?
*/
int n, final_ans, cz1, cz2;
int a1[N], a2[N], b[N];
void work(){
	cin >> n;
	for (re i = 1 ; i <= n ; ++ i)
		cin >> a1[i];
	for (re i = 1 ; i <= n ; ++ i)
		{cin >> b[i]; a2[i] = a1[n-i+1];}
	cz2 = 1;
	for (re i = 1 ; i <= n ; ++ i){
		if (a1[i] != b[i])
			cz1 ++;
		if (a2[i] != b[i])
			cz2 ++;
	}
	if (cz1 > cz2)
		cout << cz2 << '\n';
	else 
		cout << cz1 << '\n';
}
// #define IXINGMY
char_phi main(){
    #ifdef IXINGMY
        FBI_OPENTHEDOOR(a);
    #endif
    Fastio_setup();
    work();
    return GMY;
}

\[\Huge\mathbf{从这里往下都是部分分!} \]


\(\mathfrak{T2}\ 灵山之上神风起\)

这个题我就是把特殊性质搞了搞然后水了一发\(\texttt{XIN}\)

然后拿到\(60pts\)走人

T2
#include <iostream>
#include <bitset>
#define GMY (520&1314)
#define FBI_OPENTHEDOOR(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define re register int
#define char_phi signed
#define MARK cout << "###"
#define MARKER "@@@"
#define LMARK "!!!~~~"
#define ZY " qwq "
#define _ ' '
#define Endl cout << '\n'
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define N 100005
using namespace std;
inline void Fastio_setup(){ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);}
/*
	太神奇了真的
	竟然两发A了
	为什么是两发因为看错数据范围了
	一定要注意看清数据范围啊!
	让我想想
	暴力思路很好想
	暴力建图
	然后边权为1跑dijskra
	每一个点都跑一遍
	诶不对
	开一个二维bitset
	暴力记录..?
	谔谔
	开得下倒是开得下..
	但是..
	我先写一下吧
	毕竟这玩意是n^2的
	一千多MiB
	不对 这玩意何止n^2
	咋求最大独立集阿
	把n<=10的暴力拿了算了
	似乎不能二分
	漂亮,把性质B给搞了
	等等,怎么乱输出能A这么多..
*/
char A, B;
int n, final_ans;
// int col[N];
int ch[N], col[N];
bitset<N> a[N];
inline void check(){
	for (re i = 1 ; i <= final_ans ; ++ i){
		for (re j = i+1 ; j <= final_ans ; ++ j){
			if (a[ch[i]][ch[j]] == true)
				return ;
		}
	}
	cout << final_ans << '\n';
	exit(0);
}
void XIN_team(int x, int hmy){
	if (x == n+1)
		return ;
	if (hmy == final_ans){
		check();
		return ;
	}
	// 选
	ch[hmy+1] = x;
	XIN_team(x+1, hmy+1);
	// 不选
	XIN_team(x+1, hmy);
}
void work(){
	cin >> n;
	A = true; B = true;
	for (re i = 1 ; i <= n ; ++ i){
		cin >> col[i];
		if (col[i] == 2)
			A = false;
		else if (col[i] == 3)
			A = false, B = false;
	}
	if (A == true){
		cout << n << '\n';
		return ;
	}
	if (B == true){
		for (re i = 1 ; i <= n ; ++ i)
			final_ans += (col[i] == 1);
		if (final_ans == 0)
			final_ans = 1;
		if (col[1] == 2)
			final_ans ++;
		cout << final_ans << '\n';
		return ;
	}
	for (re i = 1 ; i <= n ; ++ i){
		if (col[i] == 2){
			for (re j = 1 ; j < i ; ++ j)
				a[j][i] = true;// 小在前大在后
		}
		else if (col[i] == 3){
			for (re j = i+1 ; j <= n ; ++ j)
				a[i][j] = true;
		}
	}
	for (re num = n ; num >= 1 ; -- num){
		final_ans = num;
		XIN_team(1, 0);
	}
	cout << 0 << '\n';
}
// #define IXINGMY
char_phi main(){
    #ifdef IXINGMY
        FBI_OPENTHEDOOR(a);
    #endif
    Fastio_setup();
    work();
    return GMY;
}

$\mathfrak{T3}\ 来自地上的支援 $

按照题意模拟水\(40\)

T3
#include <iostream>
#include <cstring>
#define GMY (520&1314)
#define FBI_OPENTHEDOOR(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define int long long 
#define re register int
#define char_phi signed
#define MARK cout << "###"
#define MARKER "@@@"
#define LMARK "!!!~~~"
#define ZY " qwq "
#define _ ' '
#define Endl cout << '\n'
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define N 100005
using namespace std;
inline void Fastio_setup(){ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);}
/*
	你这题意说的不清楚
	什么叫选中啊
	现在搞懂了
	你这题真麻烦
	看不懂是干啥的
	按照题意模拟吧
	需要nlogn吗dsu
	我先看部分分能拿多少
*/
char appear;
int n, Q, v, xi, ki, ans1, ans, tms, mx, mxid;
long long ans2;
int A[N], a[N], b[N];
inline char check(int mid){
	a[xi] = mid; tms = 0; appear = false;
	// cerr << "basic_information: " << xi << _ << mid << _ << a[xi] << '\n';
	// memcpy(b, a, sizeof(b));
	b[1] = a[1], b[1] += v, mx = b[1], mxid = 1;
	if (xi == 1)
		tms = 1;
	// cerr << xi << _ << mid << _ << a[xi] << '\n';
	// cerr << 1 << _ << b[1] << _ << mxid << _ << b[mxid] << '\n';
	for (re i = 2 ; i <= n ; ++ i){
		b[i] = a[i];
		if (b[i] > mx){
			mx = b[i], mxid = i;
		}
		else if (b[i] == mx){
			if (a[i] > a[mxid]){
				mxid = i;
			}
			// 其他情况就都是维持mxid不变了
		}
		// 上面是找到[1, i]中的最大值
		b[mxid] += v; mx = b[mxid];
		// cerr << i << _ << b[i] << _ << mxid << _ << b[mxid] << '\n';
		if (mxid == xi)
			{++ tms; appear = true;}
		if (tms == ki)
			return true;
		if (appear == true and mxid != xi)// 以后再也不会选中xi了
			return false;
	}
	return false;
}
void work(){
	cin >> n >> Q >> v;
	for (re i = 1 ; i <= n ; ++ i)
		{cin >> A[i]; a[i] = A[i];}
	int L, R, mid;
	while (Q --){
		cin >> xi >> ki;
		if (n-xi+1 < ki)
			continue;
		L = 0, R = 1000000000; ans = 0;
		while (L <= R){
			mid = (L+R) >> 1;
			if (check(mid) == true)
				{R = mid-1; ans = mid;}
			else 
				L = mid+1;
			// cerr << '\n' << '\n' << '\n';
		}
		// cerr << '\n' << "this time: " << ans ;
		a[xi] = A[xi];
		ans1 ^= ans, ans2 += ans;
	}
	// cerr << '\n' << "final: ";
	cout << ans1 << _ << ans2 << '\n';
}
// #define IXINGMY
char_phi main(){
    #ifdef IXINGMY
        FBI_OPENTHEDOOR(a);
    #endif
    Fastio_setup();
    work();
    return GMY;
}

\(\mathfrak{T4}\ 夜空中的UFO恋曲\)

这个题我也是乱搞

首先先猜特殊性质

然后直接猜输出\(a^{2c} ⊕ c\)

然后就水到了\(35pts\)

第一个\(subtask\)按照题意递归\(\%\)你,然后就又水到了\(25pts\)

结合一下水到\(60pts\)

T4
#include <iostream>
#include <cctype>
#define GMY (520&1314)
#define FBI_OPENTHEDOOR(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define re register int
#define char_phi signed
#define MARK cout << "###"
#define MARKER "@@@"
#define LMARK "!!!~~~"
#define ZY " qwq "
#define _ ' '
#define Endl cout << '\n'
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define ll __int128
using namespace std;
// inline void Fastio_setup(){ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);}
/*
	把T2的性质B搞出来了就是舒爽
	T4
	你这不会又是打表吧
	我超
	10^18
	第一个subtask模拟即可
	考虑性质A
	c是偶数,那他二进制第一位就是0
	也就是说他的lowbit不为1
	本来确实可以递归处理
	但是a太大了
	所以用一个__int128
	希望可以递推
	希望可以拿到点分
	我竟然还记得快读快输怎么写
	别问我,我也不知道我怎么就猜到了性质A。。。
*/
ll a, b, c, an;
inline ll read(){
	ll x = 0; char phi;
	while (!isdigit(phi = getchar()));
	do{
		x = (x << 3) + (x << 1) + (phi & 15);
	}while (isdigit(phi = getchar()));
	return x;
}
inline void ot(ll x){
	if (x > 9) ot(x/10);
	putchar((x%10)+48);
}
inline ll ksm(ll A, ll B){
	ll res(1);
	while (B != 0){
		if ((B & 1) == 1) res = res * A;
		A = A * A;
		B >>= 1;
	}
	return res;
}
ll f(ll x, ll k){
	// if (k == 1)
	return ((k == 1) ? (ksm(x, 2*c) xor c) : (f((ksm(x, 2*c)^c), k-1)));
	// return f((ksm(x, 2*c)^c), k-1);
	/*for (ll w = k ; w >= 1 ; -- w){
		x = (ksm(x, 2*c) xor c);
	}
	return x;*/
}
void work(){
	a = read(), b = read(), c = read();
	an = (((c & 1) == 0) ? ((ksm(a, 2*c)) xor c) : (f(a, b)));
	// an = ((ksm(a, 2*c)) xor c);
	ot((an & (-an))), putchar('\n');
}
// #define IXINGMY
char_phi main(){
    #ifdef IXINGMY
        FBI_OPENTHEDOOR(a);
    #endif
    // Fastio_setup();
    work();
    return GMY;
}

\[ \Huge \mathbf{别看啦,T5T6不会,暴力都不会} \]

总结

\(Luogu\)月赛的题还是乱搞比较多?

应该是我太蒻了

posted @ 2022-09-10 21:49  char_phi  阅读(144)  评论(0)    收藏  举报