Codeforces Round #684 (Div. 2) 11/17

比赛链接

T1

中文题意:
T组输入,每次第一行输入4个整数 n , c 0 , c 1 , h n,c_0,c_1,h n,c0,c1,h,第二行给出一个长度为n的二进制串。你可以花费h把它某一位取反。最终你要花 c 0 c_0 c0买下全部的0, c 1 c_1 c1买下全部的1,问最小的花费是多少。
T ≤ 10 , n , c 0 , c 1 , h ≤ 1 0 3 T\leq10,n,c_0,c_1,h\leq10^3 T10,n,c0,c1,h103

简单思维,换掉一位一定是花费更少才会换,那么这个换了花费更少,那就把全部0都要换掉或者1换掉。所以总结,要么全换1 or 0,或者一次都不换。

void solve() {
	ll n = read(), c0 = read(), c1 = read(), h = read();
	char s[1005];
	scanf("%s", s);
	ll ans = 0;
	ll cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < n; ++i)
		if (s[i] == '0')	++cnt0;
		else ++cnt1;
	if (c0 >= c1 + h)
		ans = cnt0 * h + n * c1;
	else if (c1 >= c0 + h)
		ans = cnt1 * h + n * c0;
	else
		ans = cnt1 * c1 + cnt0 * c0;
	print(ans);
}

T2

中文题意:
T组输入,每组输入第一行输入n,k,第二行有 n ∗ k n*k nk个数。你要把这些数分隔成k组,每组n个元素,问这k组数据的中位数和最大是多少?
T ≤ 100 , 1 ≤ n , k ≤ 1 0 3 , a i ≤ 1 0 9 T\leq100,1\leq n,k\leq10^3,a_i\leq10^9 T100,1n,k103,ai109

简单思维,按照下面的放法会求得全部数中位数最大,按照从小打到排序后,每次取后面没取的 ⌈ n 2 ⌉ \lceil\frac{n}{2}\rceil 2n个数,其他从前面凑。找到规律即可。
在这里插入图片描述
在这里插入图片描述

const int N = 1e5 + 7;
 
int n, m;
int a[1000005];
void solve() {
	ll ans = 0;
	n = read(), m = read();
	for (int i = 1; i <= n * m; ++i)	a[i] = read();
	sort(a + 1, a + 1 + n * m);
	int pos = m * ((n + 1 >> 1) - 1) + 1;
	int len = n - (n + 1 >> 1) + 1;
	while (m--)	ans += a[pos], pos += len;
	print(ans);
}

T3

中文题意:
T组输入,每组输入第一行n,m代表矩阵规模,接着给出一个01矩阵,你每次可以选择 2 ∗ 2 2*2 22的小矩阵,翻转其中的3个元素,0变1,1变0,如果限制你最多可以操作的次数为 3 ∗ n ∗ m 3*n*m 3nm,要你输出你选择的方案操作次数k,以及k次操作具体反转了哪3个点。
T ≤ 5000 , 2 ≤ n , m ≤ 100 T\leq5000,2\leq n,m\leq100 T5000,2n,m100

模拟题,观察发现我们可以检测每一个矩阵,我们找到矩阵中1的变化规律是。
4 → 1 → 2 → 3 → 0 4\to1\to2\to3\to0 41230,这里给的 3 ∗ n ∗ m 3*n*m 3nm很大,观察发现遍历即可,难点在C4。

#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define all(__vv__) (__vv__).begin(), (__vv__).end()
#define endl "\n"
#define pai pair<int, int>
#define ms(__x__,__val__) memset(__x__, __val__, sizeof(__x__))
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())	s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void print(ll x, int op = 10) { if (!x) { putchar('0'); if (op)	putchar(op); return; }	char F[40]; ll tmp = x > 0 ? x : -x;	if (x < 0)putchar('-');	int cnt = 0;	while (tmp > 0) { F[cnt++] = tmp % 10 + '0';		tmp /= 10; }	while (cnt > 0)putchar(F[--cnt]);	if (op)	putchar(op); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;	while (b) { if (b & 1)	ans *= a;		b >>= 1;		a *= a; }	return ans; }	ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
const int dir[][2] = { {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;

int n, m, mp[N][N];
struct Node {
	int x[3], y[3];
	int cnt;
}ans[3 * N * N];
int tot;

int calc(int x, int y) {
	return mp[x][y] + mp[x + 1][y] + mp[x][y + 1] + mp[x + 1][y + 1];
}

void push(int pos, int i, int j) {
	ans[pos].x[ans[pos].cnt] = i;
	ans[pos].y[ans[pos].cnt] = j;
	++ans[pos].cnt;
}

void check(int x, int y) {
	int tmp = calc(x, y);
	if (tmp == 0)	return;
	if (tmp == 4) {
		push(tot, x, y);
		push(tot, x + 1, y);
		push(tot, x, y + 1);
		++tot;
		mp[x][y] = mp[x + 1][y] = mp[x][y + 1] = 0;
		tmp = 1;
	}
	if (tmp == 1) {
		int flag = 0;
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1) {
					mp[i][j] = 0;
					push(tot, i, j);
				}
				else if (flag < 2) {
					mp[i][j] = 1;
					push(tot, i, j);
					++flag;
				}
			}
		++tot;
		tmp = 2;
	}
	if (tmp == 2) {
		int flag0 = 0, flag1 = 0;
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1 and flag1 == 0) {
					mp[i][j] = 0;
					push(tot, i, j);
					++flag1;
				}
				else if (mp[i][j] == 0 and flag0 < 2) {
					mp[i][j] = 1;
					push(tot, i, j);
					++flag0;
				}
			}
		++tot;
		tmp = 3;
	}
	if (tmp == 3) {
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1) {
					mp[i][j] = 0;
					push(tot, i, j);
				}
			}
		++tot;
	}
}

void print(Node& ans) {
	printf("%d %d ", ans.x[0], ans.y[0]);
	printf("%d %d ", ans.x[1], ans.y[1]);
	printf("%d %d\n", ans.x[2], ans.y[2]);
}

void solve() {
	n = read(), m = read();
	char s[N];
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++) {
			mp[i][j] = s[j] - '0';
		}
	}
	tot = 0;
	for (int i = 0; i < 3 * N * N; ++i)	ans[i].cnt = 0;
	for (int i = 1; i < n; i++)
		for (int j = 1; j < m; j++) {
			check(i, j);
		}
	print(tot);
	for (int i = 0; i < tot; i++)
		print(ans[i]);
}

int main() {
	int T = 1;
	T = read();
	while (T--) {
		solve();
	}
	return 0;
}

T4

题意与上题几乎一致,但是把限制 k ≤ 3 ∗ n ∗ m k\leq 3*n*m k3nm改为了 k ≤ n ∗ m k\leq n*m knm
4 → 1 → 2 → 3 → 0 4\to1\to2\to3\to0 41230,每个矩阵最多花费4步,如果行列是偶数的话,刚好可以分完矩阵,所以 k ≤ n ∗ m k\leq n*m knm成立,如果是奇数的话我们要处理最后一行或者最后一列全部先为0,接着上面偶数的方法,假设 n , m n,m n,m都是奇数,方法步骤是 k ≤ n + 1 2 + m + 1 2 + ( n − 1 ) ∗ ( m − 1 ) k\leq \frac{n+1}{2}+\frac{m+1}{2} + (n-1)*(m-1) k2n+1+2m+1+(n1)(m1),这样就符合了k的要求了。
)这个大模拟题目挺有意思收录了。

#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define all(__vv__) (__vv__).begin(), (__vv__).end()
#define endl "\n"
#define pai pair<int, int>
#define ms(__x__,__val__) memset(__x__, __val__, sizeof(__x__))
#define rep(i, sta, en) for(int i=sta; i<=en; ++i)
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())	s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void print(ll x, int op = 10) { if (!x) { putchar('0'); if (op)	putchar(op); return; }	char F[40]; ll tmp = x > 0 ? x : -x;	if (x < 0)putchar('-');	int cnt = 0;	while (tmp > 0) { F[cnt++] = tmp % 10 + '0';		tmp /= 10; }	while (cnt > 0)putchar(F[--cnt]);	if (op)	putchar(op); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;	while (b) { if (b & 1)	ans *= a;		b >>= 1;		a *= a; }	return ans; }	ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
const int dir[][2] = { {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;

int n, m, mp[N][N];
struct Node {
	int x[3], y[3];
	int cnt;
}ans[N * N];
int tot;

int calc(int x, int y) {
	return mp[x][y] + mp[x + 1][y] + mp[x][y + 1] + mp[x + 1][y + 1];
}

void push(int pos, int i, int j) {
	ans[pos].x[ans[pos].cnt] = i;
	ans[pos].y[ans[pos].cnt] = j;
	++ans[pos].cnt;
}

void check(int x, int y) {
	int tmp = calc(x, y);
	if (tmp == 0)	return;
	if (tmp == 4) {
		push(tot, x, y);
		push(tot, x + 1, y);
		push(tot, x, y + 1);
		++tot;
		mp[x][y] = mp[x + 1][y] = mp[x][y + 1] = 0;
		tmp = 1;
	}
	if (tmp == 1) {
		int flag = 0;
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1) {
					mp[i][j] = 0;
					push(tot, i, j);
				}
				else if (flag < 2) {
					mp[i][j] = 1;
					push(tot, i, j);
					++flag;
				}
			}
		++tot;
		tmp = 2;
	}
	if (tmp == 2) {
		int flag0 = 0, flag1 = 0;
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1 and flag1 == 0) {
					mp[i][j] = 0;
					push(tot, i, j);
					++flag1;
				}
				else if (mp[i][j] == 0 and flag0 < 2) {
					mp[i][j] = 1;
					push(tot, i, j);
					++flag0;
				}
			}
		++tot;
		tmp = 3;
	}
	if (tmp == 3) {
		for (int i = x; i <= x + 1; ++i)
			for (int j = y; j <= y + 1; ++j) {
				if (mp[i][j] == 1) {
					mp[i][j] = 0;
					push(tot, i, j);
				}
			}
		++tot;
	}
}

void check1(int x, int y) { // 处理奇数最后一列
	int tmp = calc(x, y);
	if (!tmp)	return;
	if (tmp == 2) {
		push(tot, x, y), mp[x][y] = 0;
		push(tot, x + 1, y), mp[x + 1][y] = 0;
		push(tot, x, y - 1), mp[x][y - 1] ^= 1;
		++tot;
	}
	else {
		if (mp[x][y])	push(tot, x, y), mp[x][y] = 0;
		else push(tot, x + 1, y), mp[x + 1][y] = 0;
		push(tot, x, y - 1), mp[x][y - 1] ^= 1;
		push(tot, x + 1, y - 1), mp[x + 1][y - 1] ^= 1;
		++tot;
	}
}

void check2(int x, int y) { // 处理奇数最后一行
	int tmp = calc(x, y);
	if (!tmp)	return;
	if (tmp == 2) {
		push(tot, x, y), mp[x][y] = 0;
		push(tot, x, y + 1), mp[x][y + 1] = 0;
		push(tot, x - 1, y), mp[x - 1][y] ^= 1;
		++tot;
	}
	else {
		if (mp[x][y])	push(tot, x, y), mp[x][y] = 0;
		else push(tot, x, y + 1), mp[x][y + 1] = 0;
		push(tot, x - 1, y), mp[x - 1][y] ^= 1;
		push(tot, x - 1, y + 1), mp[x - 1][y + 1] ^= 1;
		++tot;
	}
}

void print(Node& ans) {
	printf("%d %d ", ans.x[0], ans.y[0]);
	printf("%d %d ", ans.x[1], ans.y[1]);
	printf("%d %d\n", ans.x[2], ans.y[2]);
}

void solve() {
	n = read(), m = read();
	char s[N];
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++) {
			mp[i][j] = s[j] - '0';
		}
	}
	tot = 0;
	for (int i = 0; i < N * N; ++i)	ans[i].cnt = 0;
	if (n % 2 == 1 and m % 2 == 1) {
		check2(n, m - 1); // 把n,m点变成0
		for (int i = 1; i < n; i += 2)
			check1(i, m);
		for (int i = 1; i < m; i += 2)
			check2(n, i);
	}
	else if (n % 2) {
		for (int i = 1; i < m; i += 2)
			check2(n, i);
	}
	else {
		for (int i = 1; i < n; i += 2)
			check1(i, m);
	}
	for (int i = 1; i < n; i += 2)
		for (int j = 1; j < m; j += 2) {
			check(i, j);
		}
	print(tot);
	for (int i = 0; i < tot; i++)
		print(ans[i]);
}

int main() {
	int T = 1;
	T = read();
	while (T--) {
		solve();
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值