2024牛客暑期多校训练营1

Sum of Suffix Sums

Given an array which is initially empty, you need to perform q operations:

Given two non-negative integers t and v, take out the element from the end of the array for t times and then append v to the end of the array. It is guaranteed that t does not exceed the length of the array before this operation

After each operation, let a1,a2,...,an​ be the current array, find the sum of s1,s2,...,snwhere si=ai+ai+1+...+an is the sum of the suffix starting from position iii.

World Finals

The ICPC World Finals are coming. Due to some reasons, the 46th and 47th World Finals will be held simultaneously. For the teams qualified in both competitions, they should choose one to take part in.

The first line contains one integer n (1≤n≤105), denoting the number of teams qualified in the 46th World Finals.

Next n lines each contain one string S (1≤∣S∣≤10) and two integers p,t (1≤p,t≤109)p,,denoting the name, the predicted number of solved problems, and time penalty of one team in the 46th World Finals respectively.

Next one line contains one integer m (1≤m≤105), denoting the number of teams qualified in the 47th World Finals.

Next m lines each contain one string S (1≤∣S∣≤10)Sand two integers p,t (1≤p,t≤109), denoting the name, the predicted number of solved problems, and time penalty of one team in the 47th World Finals respectively.

Output one line containing one integer, denoting the best possible ranking of lzr010506's team.

the competition choices of the double-qualified teams can be arbitrarily arranged by him.

复制代码
#include<bits/stdc++.h>

using namespace std;

#define int long long

struct node{
	string name;
	int s;
	int t;
};

bool cmp(node a, node b){
	if(a.s > b.s)
		return true;
	else if(a.s == b.s)
		return a.t < b.t;
	return false;
}

void solve(){
	vector<node> q1;
	vector<node> q2;
	unordered_map<string, int> st1;
	unordered_map<string, int> st2;
	int n, m;
	cin >> n;
	for(int i = 0; i < n; i ++){
		string a;
		int s, t;
		cin >> a >> s >> t;
		q1.push_back({a, s, t});
		if(!st1.count(a))
			st1[a] = 1;
	}
	cin >> m;
	for(int i = 0; i < m; i ++){
		string a;
		int b, c;
		cin >> a >> b >> c;
		q2.push_back({a, b, c});
		if(!st2.count(a))
			st2[a] = 1;
	}
	sort(q1.begin(), q1.end(), cmp);
	sort(q2.begin(), q2.end(), cmp);
	int cnt1 = 0;
	for(int i = 0; i < n; i ++){
		if(q1[i].name == "lzr010506"){
			cnt1 ++;
			break;
		}
		if(!st2.count(q1[i].name))
			cnt1 ++;
	}
	int cnt2 = 0;
	for(int i = 0; i < m; i ++){
		if(q2[i].name == "lzr010506"){
			cnt2 ++;
			break;
		}
		if(!st1.count(q2[i].name))
			cnt2 ++;
	}

	cout << min(cnt1, cnt2);
	
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

A Bit Common

Given two integers n and m, among all the sequences containing n non-negative integers less than 2^m, you need to count the number of such sequences A that there exists a non-empty subsequence of A in which the bitwise AND of the integers is 1

Note that a non-empty subsequence of a sequenceA is a non-empty sequence that can be obtained by deleting zero or more elements from AAA and arranging the remaining elements in their original order.

Since the answer may be very large, output it modulo a positive integer q.

The bitwise AND of non-negative integers AAA and BBB, A AND BA\ \texttt{AND}\ BA AND B is defined as follows:

GCD VS XOR

Red Walking on Grid

Red is on a 2⋅n, with some cells being red and others being white.

Red can initially choose a red cell, and at each step, can choose a red cell above, below, to the left, or to the right. When Red leaves a cell, the cell immediately turns white.

Red wants to know the maximum number of steps she can take.

If there are no initial red cells, please output 0.

相关推荐
小此方1 小时前
[算法实战论:动态规划]回文串问题的dp解法,回文串问题的母题,以及以此为基础的派生题
算法·动态规划
Pniubi1 小时前
力扣560.和为k的子数组
算法·leetcode·职场和发展
D e re k ZH2 小时前
C++ 从零入门(一):基础语法与程序结构
数据结构·c++·算法
Pniubi2 小时前
力扣438.找到字符串中所有字母异位词
算法·leetcode·职场和发展
東隅已逝,桑榆非晚5 小时前
算法6. 双指针法-查找总价格为目标的两个商品
c++·学习·算法
Eyfcom5 小时前
〖物联网终端实战 01〗UWB 室内高精度定位:仓储 AGV 与人员的厘米级轨迹追踪
物联网·算法·物流系统·快递系统·跨境物流快递系统·物联网终端实战
bro_Java6666 小时前
《排序的底层逻辑:比较、交换与分治》
java·算法·排序算法
爱喝雪碧的可乐6 小时前
MATLAB
开发语言·算法·matlab
叼烟扛炮7 小时前
Linux 学习笔记(六十):单线程的逆袭——epoll 高并发服务器实战
linux·服务器·网络·笔记·学习·算法
careathers7 小时前
【数据结构】基于比较的排序算法 - 交换排序
数据结构·算法·排序算法