op.empty()) anso.push_back(op.top()), op.pop(); while (!num.empty()) ansn.push_back(num.top()), num.pop(); } else { bool odd_enough = 0; for (int i = n - 1; ~i; --i) if (c[i] & 1) while (c[i]) { if (z) --z, anso.push_back('^'); else goto ...
Hello! The problems from the 2022 ICPC Asia-Manila Regionals have been uploaded to the Codeforces Gym. I'm quite happy with this set, and would like to share the problems with anyone else who might be interested :)) https://codeforces.com/gym/104118 I hope you enjoy!
给定序列a1,a2,⋯ ,ana1,a2,⋯,an。 我们需要选择若干元素(可以不选),满足如果选择了aiai,那么序列中所有长度为ii的区间中都最多只有两个元素被选择。 最大化选择的元素的和。 Solution 显然,考虑到假设我们选择的编号最大的元素为apap,那么区间[1,p][1,p]中也应该最多两个元素。
#include<bits/stdc++.h>usingnamespacestd;voidsolve(){ string s; map<char,int> mp; cin >> s;intmx =0;for(charch : s) { mp[ch]++; mx =max(mx, mp[ch]); } cout << s.size() - mx <<'\n'; }intmain(){ ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);intt ...
int ah[N]; int bh[N]; int at[N], atc[N]; int bt[N], btc[N]; int n, m; double as, bs, cnt; void dfs(int huihe, int o, double s) { int flagn = 0, flagm = 0; for(int i = 1; i <= n; i++) { if(ah[i] > 0) ...
// https://ac.nowcoder.com/acm/contest/32708/E #include "stdafx.h" #include <algorithm> #include <iostream> #include <cstring> using namespace std; const int N = 1E5 + 100; int n, m, block; int arr[N]={ 0,1, 2, 3,4, 1,2,3 ...
QOJ: The 2022 ICPC Asia Hong Kong Regional Contest Macesuted/CodePublic NotificationsYou must be signed in to change notification settings Fork4 Star32 Code Issues Pull requests Discussions Actions Security Insights Additional navigation options
我们发现我们可以用前缀和计算1 - i的区间贡献,我们单循环扫一遍即可。但是一个左右端点都不确定的区间的贡献是不是s[r] - s[l - 1]呢?显然因为有环的存在,是不对的。加入有这样一个区间111000111,其实实际上有6个1连续,贡献为3,但是我们可能会把贡献算成2 + 2。因此不对的,差分算区间一定要保证两端都...
显然当且仅当所有字符均相等才为完美回文。 字符集只有 26,直接做就行了。 #include<bits/stdc++.h> usingnamespacestd; #defineint long long constintN=1e6+5; intT; chars[N]; inta[300]; signedmain(){ cin>>T; while(T--){ scanf("%s",s+1); ...
操作需要先选一个点u,选择u的所有深度为i的儿子,将这些儿子的点的颜色涂黑 n个点一开始全是白色,求全涂黑的最小代价 sumn不超过3e5 思路来源 网上搜到的长剖题解 题解 dp[u][i]表示根为u的深度i全被染黑的最小代价,有朴素转移: dp[u][i]=min(a[i],∑v∈son[u]dp[v][i+1]) ...