atcoder another contest string
AtCoder Beginner Contest 331 G - Collect Them All【概率期望+容斥+多项式】
题目链接:ABC331_G 写在前面 将来如果回顾这道题,建议自己看完题意一定先重新推一遍。如果还是不够熟练,多去做一些同类型的题目吧。 题意: 盒子里有 \(N\) 张卡片,每张卡片上写着一个数字,数字的范围是 \(1,...,M\),写着数字 \(i\) 的卡片有 \(C_i\) 张\((C_i ......
string 的扩容机制
C++ string 类的扩容机制主要取决于编译器的实现,但一般来说,它们都遵循一种动态数组的策略,即当字符串的大小超过当前容量时,就会分配更大的内存空间。以下是一种常见的扩容策略1: size_type _Grow_to(size_type _Count) const { size_type _C ......
2023 (ICPC) Jiangxi Provincial Contest -- Official Contest
Preface 伟大的徐神终于来和我们一起训练了,然后这场中期一眼秒了可做题中最难的G 虽然中间因为我搞错了徐神的意图给徐神原来正确的主席树删了搞了个错的上去浪费了快一个小时 但无所谓最后结束前把所有可做题全写了强势捧杯(打弱省省赛打出自信了属于是) A. Drill Wood to Make Fi ......
AtCoder Beginner Contest 331
C - Sum of Numbers Greater Than Me 题意:给定一个长度为n的数组,分别找出比a[i]大的数组里的数的和 思路:用map记录每个数的个数,然后遍历一遍,后面一个项就是数组之和-前面一项-前面的累加 #define int long long using namespa ......
Daiwa Securities Co. Ltd. Programming Contest 2023(AtCoder Beginner Contest 331)
Daiwa Securities Co. Ltd. Programming Contest 2023(AtCoder Beginner Contest 331) A - Tomorrow 解题思路: 模拟。 代码: #include <bits/stdc++.h> using namespace s ......
C++中String^类型如何处理(String^转换为char*)
.cpp头文件中需包括 using namespace System; //String^库文件 using namespace System::Runtime::InteropServices; //Marchal库文件 函数内容 char* c = "adsfdasf"; String^ str ......
PHP ‘Array and string offset access syntax with curly braces is deprecated’ 错误的原因和解决办法...
其实从错误信息里就看出错误原因了:Array and string offset access syntax with curly braces is deprecated,这是 PHP 7.4 版本的更新,从 7.4 后,只能使用 $value[0] 的方式来获取字符串偏移,$value{0} 已 ......
Atcoder-ABC317G-Rearranging
ABC317G - Rearranging 题意 给出一个 \(n\) 行 \(m\) 列的矩阵,可以将每一行的 \(m\) 个数重新排列,问能不能得到 \(m\) 列都是 \(n\) 的排列的矩阵,能得到则输出任意一个方案。 给出的矩阵满足对于 \(i \in [1,n]\) ,都恰好出现了 \( ......
Atcoder-ARC165F-Make Adjacent
ARC 165 - F - Make Adjacent Statement 给定一个长度为 \(2n\) 的数列 \(a\) ,其中对于每个数 \(i \in [1,n]\),恰好在 \(a\) 中出现两次。每次可以将两个相邻的数交换。最后要求 \(\forall i \in [1,n] : a_{ ......
[LeetCode] 1903. Largest Odd Number in String
You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or ......
使用 std::string_view 提升字符串处理性能
C++标准库提供了一个非常优秀的字符串处理类std::string,我们可以通过该类完成各种字符串操作。但是std::string有一个缺点,它的很多操作都是针对字符串实体,存在不必要的内存拷贝的代码,导致字符串的处理性能不尽如人意。 针对这种情况C++17标准引入了std::string_view ......
string 是否线程安全
线程安全是什么 线程安全是指在多线程环境下,程序的执行能够正确地处理多个线程并发访问共享数据的情况,保证程序的正确性和可靠性。 type StringHeader struct { Data uintptr //存放指针,其指向具体的存储数据的内存区域 Len int //字符串的长度 } 并发访问 ......
AtCoder Beginner Contest 复盘合集
AtCoder Beginner Contest 复盘合集 2023.12.6 ABC312 VP(OI赛制) 这次的ABC相对比较难:红橙黄黄蓝绿绿,Ex(蓝) A: #include <bits/stdc++.h> using namespace std; vector<string> v; s ......
CF1809D Binary String Sorting 题解
题意: 思路: 贪心: 单调不降的 $ 01 $ 字符串,一定是一串连续的 $ 0 $ 再加上一串连续的 $ 1 $ 。由于每次操作的代价很大,所以需要在操作次数尽可能少的情况下,尽可能多地使用交换操作。 由于 $ 1 $ 次交换操作,只能减少 $ 1 $ 个逆序对,当存在多个逆序对时,优先通过删除 ......
The 2022 ICPC Asia Hangzhou Regional Contest
A. Modulo Ruins the Legend 首先题目要求的是$(\sum (a_i + s + i \times d))% m $的最小值 等价于求\((\sum a_i + n\times s + \frac{n(n+1)}{2} \times d) \%m\)的最小值 令\(sum = ......
[Codeforces Round 855 (Div. 3)](https://codeforces.com/contest/1800)
Codeforces Round 855 (Div. 3) A. Is It a Cat? 为什么这个A这么麻烦 #include <bits/stdc++.h> #define int long long #define endl '\n' using namespace std; void so ......
AtCoder Beginner Contest 331
A - Tomorrow (abc331 A) 题目大意 给定一年的月数和一月的天数,以及当天日期,问次日的日期。 解题思路 一个简单的进制加法运算,超出进制数则向前加一。 神奇的代码 #include <bits/stdc++.h> using namespace std; using LL = ......
[LeetCode] 2264. Largest 3-Same-Digit Number in String
You are given a string num representing a large integer. An integer is good if it meets the following conditions: It is a substring of num with length ......
The 2023 ICPC Asia Hong Kong Regional Programming Contest (AEFHKL)
在考试周打比赛就像在刀尖上跳舞,在赌桌上下筹码 我只希望专业课它别挂 不然搞钱吃饭就麻烦了 A.TreeScript 学弟写的,阅读理解题,读对了就是简单树dp #include<bits/stdc++.h> using namespace std; const int N=2e5; int n,f ......
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $ package com.example.core.mydemo.scooterOrderSms; impor ......
The 13th Shandong ICPC Provincial Collegiate Programming Contest
A. Orders 按照订单的结束时间排序,然后遍历一遍即可 #include<bits/stdc++.h> using namespace std; #define int long long using pii = pair<int, int>; using i32 = int32_t; voi ......
[Educational Codeforces Round 159 (Rated for Div. 2)](https://codeforces.com/contest/1902)
Educational Codeforces Round 159 (Rated for Div. 2) 好困,差点没打 A - Binary Imbalance #include <bits/stdc++.h> #define int long long #define endl '\n' usin ......
AtCoder Beginner Contest 328
AtCoder Beginner Contest 328 链接:Toyota Programming Contest 2023#7(AtCoder Beginner Contest 328) - AtCoder A 题意:给定n个数,将小于等于x的数加起来输出。 #include <bits/std ......
AtCoder Beginner Contest 331
AtCoder Beginner Contest 331 这场状态好差,下午的校赛也打的好差。 A - Tomorrow #include <bits/stdc++.h> #define int long long #define endl '\n' using namespace std; voi ......
AtCoder Beginner Contest 331 G Collect Them All
洛谷传送门 AtCoder 传送门 设数字 \(i\) 第一次拿到的时间为 \(t_i\),所求即为 \(E(\max\limits_{i = 1}^m t_i)\)。 施 min-max 容斥,有: \[\begin{aligned}E(\max\limits_{i = 1}^m t_i) & = ......
2023-2024 CTU Open Contest
A. Beth's Cookies n = int(input()) s = input() res = [] for i in s : if res == []: res.append(i) elif i == '(': if res[-1] == ')': res.append("*") res ......
C++_22_string类型 - 重写版
string类型·变量定义 C++ 中提供了一个 string 内建数据类型,它可以替代 C 语言中的 char* 数组。 使用 string 数据类型时,需要在程序中包含头文件<string> #include <iostream> #include <string> using namespac ......
AtCoder Beginner Contest 331
B - Buy One Carton of Milk 难度: ⭐ 题目大意 选择有三种套餐, 6个鸡蛋S元, 8个鸡蛋M元, 12个鸡蛋L元; 问如果要买至少N个鸡蛋, 最少花费多少钱; 解题思路 一道入门级dp; 神秘代码 #include<bits/stdc++.h> #define int l ......
Go - check if an error contains a string
if err != nil { if strings.Contains(sql.ErrNoRows.Error(), err.Error()) { ctx.JSON(http.StatusNotFound, errorResponse(err)) return } ctx.JSON(http.Sta ......
The 13th Shandong ICPC Provincial Collegiate Programming Contest
Preface 昨天VP的那场没有字符串还没有原形毕露,今天遇到一个后期字符串直接和祁神大眼瞪小眼了 最后一个半小时祁神狂冲F成功写出两个version的假算法,而我已经滚去补之前欠下的题目了 赛后被徐神狠狠拷打了,评价为徐神是我们的红太阳,没有他我们都不能活 A. Orders 签到,按截止时间处 ......