25_1_4 Hello 2025
1. Hello 2025A. MEX Table(800)(constructive algorithms)(math) Ques门钥匙 题意 One day, the schoolboy Mark misbehaved, so the teacher Sasha called him to the whiteboard. Sasha gave Mark a table with rows and columns. His task is to arrange the numbers in the table (each number must be used exactly once) in such a way as to maximize the sum of MEX across all rows and columns. More formally, he needs to maximize \sum\limits_{i = 1}^{n} \operatorname{mex}(\{a_{i,1}, a_{i,2}, \ldots, a_{i,m}\}) + \...
26_5_16 Codeforces Round 1098 (Div. 2)
Codeforces Round 1098 (Div. 2)A. Marisa Steals Reimu’s Takeout门钥匙 Ques题意 The Darkness Brought In by Swallowstone Naturalis Historia — Dateless Bar “Old Adam” Marisa is a girl of integrity who always helps others safeguard their belongings. Over a period of days, she comes each day to take one of Reimu’s takeouts. The -th takeout is described by its deliciousness value — an integer (), forming a sequence of length . Marisa has a special fondness for the number . She can perform the followin...
hdoj8
hdoj83,8,5 -> 6,7,9 -> 1,10,4,2 3. 疯狂的自我搜索者Ques题意 Aya 是修车专家,但是有很多彩黑批评她的修车技术还不如劈瓦大师 Amita, Aya 在网上自搜发现有非常多彩黑,她决定将彩黑统统屏蔽。 在接下来 n分钟内,每分钟会出现 条新的彩黑评论, Aya 每分钟至多可以屏蔽 x 条之前未屏蔽过的彩黑评论,在此我们认为,每一分钟都是彩黑评论先出现,然后 Aya 开始屏蔽彩黑评论。 Aya 想知道, n 分钟后还剩余多少条彩黑评论没有被屏蔽。 Input 第一行输入一个正整数 ,表示数据组数。 对于每一组数据: 第一行输入两个正整数 ,表示分钟数,每分钟可以屏蔽的彩黑评论数量。 第二行输入 n 个正整数 ,表示每分钟会出现的彩黑评论数量。 数据保证 。 Output 对于每组数据输出一个整数表示答案。 sample 12316 31 1 4 5 1 4 12 Hint 第1分钟出现1条彩黑评论,Aya屏蔽1条彩黑评论,累计剩余0条彩黑评论。 第2分钟出现1条彩黑评论,Aya屏蔽1条彩黑评论,累计剩余0条彩黑评论。 ...
hdoj1
5,6,8 -> 2,7 -> 9,1,3 -> 4,10 1005 大户爱的开根题意对于每组数据,给定两个整数N,K,要求输出一个整数,表示⌊K⌋。题目保证 ,组数T≤100。 题解 法一参考讨论区的做法,用long double处理一下题目给的式子,就能AC了 12345void solve(){ long double n,k; cin >> n >> k; cout << floor(pow(n,1.0/k)) << '\n';} 法二枚举,从小到大枚举i表示⌊K⌋的整数,然后乘k次,得到res,若res*i>n,则直接退出,并输出i-1。当然,需要特别判断k=1的情况,否则,最差会一直到1e9。 123456789101112131415161718192021222324void solve(){ int n,k; cin >> n >> k; if(k == 1){ cout << n << '\n'; ...
栈
栈因为c++有标准STL库,所以下面将给出两个cpp和c两种版本的代码 1. 有效的括号(简单)门钥匙 Ques给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 每个右括号都有一个对应的相同类型的左括号。 cpp: bool isValid(string s); c: bool isValid(char* s); Ans简单模拟下 cpp代码1234567891011121314151617181920212223class Solution {public: bool isValid(string s) { if(s.length() & 1) return false; stack<char> st; for(char c : s)...
链表
链表准备工作链表声明1234567struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nullptr) {} ListNode(int x) : val(x), next(nullptr) {} ListNode(int x, ListNode *next) : val(x), next(next) {}}; 下面举例说明下这三个构造函数: ListNode() : val(0), next(nullptr) {} ListNode a; 表示a.val = 0,a.next = nullptr ListNode(int x) : val(x), next(nullptr) {} ListNode a(5); 表示a.val = 5,a.next = nullptr ListNode(int x, ListNode *next) : val(x), next(next) {} ListNode b(3, &a);表示b.val = 3,b.next =...
LTT L2
天梯赛 L2 速通25分L2-001 紧急救援 √考点:dijkstra 1. dist[v]:S -> v 最短距离 2. cnt[v]:最短路条数 3. sum[v]:在最短路前提下可召集的最大救援队数 并用 pre[v] 记录最优前驱,最后回溯路径。 时间复杂度 O(N^2 + M),在 N<=500 下可通过。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970using ll = long long;const int INF = 0x3f3f3f3f;struct edge{ int to,w;};void solve(){ int n,m,s,d; cin >> n >> m >> s >> d; vector<int> team(n)...
LTT L1
天梯赛 L1 速通15分1.L1-003 个位数统计==for(char c : s)== 12345678910111213void solve(){ string s; cin >> s; int cnt[10] = {0}; for(char c : s){ cnt[c-'0']++; } for(int i = 0;i < 10;++i){ if(cnt[i] != 0) cout << i << ":" << cnt[i] << '\n'; } return;} 2.L1-005 考试座位号建立映射,而不是结构体。 1234567891011121314151617181920void solve(){ int n; cin >> n; s...
2022 LTT
2022年天梯赛L1-1 今天我要赢门钥匙 题意: 输出两行:第一行固定字符串“I’m gonna win! Today!”,第二行根据“比赛前一天2022-04-23”推出当天日期,并按“年年年年-月月-日日”格式输出。 解答:签到题 1234void solve(){ cout << "I'm gonna win! Today!" << '\n'; cout << "2022-04-23" << '\n'; } L1-2 种钻石门钥匙 题意:输入需求量N(≤10⁷微克拉)和培育速度v(1≤v≤200微克拉/天)。计算培育N微克拉钻石所需整数天数(向下取整)。 解答:签到题 12345void solve(){ int n,v; cin >> n >> v; cout << n/v << '\n';} L1...
codefoces mind (T11-20)
codefoces mind (T11-20)11. Beautiful String(1000)(brute force)(constructive algorithms) Ques门钥匙 题意 You are given a binary string of length . Your task is to find any subsequence of such that: The subsequence is non-decreasing. That is, each character in is not greater than the next one. Let denote the string obtained by removing all characters of from , while preserving the order of the remaining characters. Then must be a palindrome. You only need to output any valid subsequence t...
