牛客周赛 Round 60(思维、逆元、组合数、概率DP)

牛客周赛 Round 60(思维、逆元、组合数、概率DP)


F题,概率DP不会,学了再补


A. 困难数学题

  • x ^ x = 0
  • 0 ^ x = x
  • ^ 表示二进制异或
#include<bits/stdc++.h>

using namespace std;

int main(){
	
	cout << 0 << endl;
	
	return 0;
}

B. 构造序列

注意是ABAB,还是ABABA

#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
	
    ll a, b;
    cin >> a >> b;
    
    cout << min(a, b) * 2 + (a != b) << endl;
    
	return 0;
}

C. 连点成线

统计每行每列出现的最大值和最小值,做差取max即可,

#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

vector<int> row[maxn], column[maxn];

int main(){
	
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int x, y;
		cin >> x >> y;
		row[x].push_back(y);
		column[y].push_back(x);
	}
	
	int res = 0;
	for(int i = 1; i <= n; i++){
		if(row[i].size() > 1){
			sort(row[i].begin(), row[i].end());
			res = max(res, *(row[i].end() - 1) - row[i][0]);	// row[i].end() 是指针,表示row[i]最后一个元素的后一位的地址
		}
		if(column[i].size() > 1){
			sort(column[i].begin(), column[i].end());
			res = max(res, *(column[i].end() - 1) - column[i][
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值