【SDUT 2021 Spring Team Contest--- 11(Kattis)题解】教程文章相关的互联网学习教程文章

【AtCoder】M-SOLUTIONS Programming Contest【代码】

M-SOLUTIONS Programming ContestA - Sum of Interior Angles#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #define eps 1e-10 #define MAXN 200005 #define ba 47 //#define ivorysi using namespace std; typedef long long int64; typedef unsigned int u32; typedef double db;...

ICPC Southeast USA 2020 Regional Contest Problem A: Ant Typing(思维)【代码】【图】

题目描述We have a knapsack of integral capacity and some objects of assorted integral sizes. We attempt to?fill the knapsack up, but unfortunately, we are really bad at it, so we end up wasting a lot of space?that can’t be further filled by any of the remaining objects. In fact, we are optimally bad at this!?How bad can we possibly be?figure out the least capacity we can use where we cannot place...

Contest 1【代码】

A:注意到模数是要求lcm的数的倍数,直接先取模就可以了。考场脑抽,对其质因数分解判了一下每个因子有没有,当然也行。#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> usingnamespace std; int read() {int x=0,f=1;char c=getchar();while (c<‘0‘||c>‘9‘) {if (c==‘-‘) f=-1;c=getchar();}while (c>=‘0‘&&c<=‘9‘) x=(x<<1)+(x<<3)+(c^48),c=getchar()...

AtCoder Regular Contest 099 E - Independence【代码】【图】

题意 给你一个无向图 不会有重边和自环然后要求你把所有点分成两个集合,每个集合的点必须是个完全图,如果满足不了上述条件 输出-1;题解:考虑建原图的补图;即,若两点之间没有边,则连边;若这个图不是二分图,那么无解,感性理解一下就行了注意你虽然是二分图,但是不一定是全联通,可能是很多个连通二分图组成然后二分图的各个连通块染色一下,统计左右两边的数目,最后o(n)的取一下最小值就行了 然后这个题细节很多,学到...

题解 UVA11865 【Stream My Contest】【代码】

最小树形图(朱刘算法)\(+\) 二分答案。由题意得,我们要在一些有向边中选出一些边,使\(0\)号节点能够到达其他节点,使距离之和\(\leqslant cost\),并且使每条边中的带宽的最小值最大。为方便起见,我将\(0 \sim n-1\)号节点都\(++\),转为\(1 \sim n\)号节点。第一个要求用最小树形图来解决,最小值最大用二分答案来解决,在二分时只选出带宽\(\geqslant mid\)的边,用选出的边求最小树形图,判断二分是否合法。多组数据以及二...

[Leetcode Weekly Contest]184【代码】

链接:LeetCode[Leetcode]5380. 数组中的字符串匹配给你一个字符串数组 words ,数组中的每个字符串都可以看作是一个单词。请你按 任意 顺序返回 words 中是其他单词的子字符串的所有单词。 如果你可以删除\(words[j]\)最左侧和/或最右侧的若干字符得到\(word[i]\),那么字符串\(words[i]\) 就是\(words[j]\)的一个子字符串。直接暴力就可以了。class Solution:def stringMatching(self, words: List[str]) -> List[str]:res = []f...

SDUT 2021 Spring Team Contest--- 11(Kattis)题解【代码】

Kattis B - Baby BitesC - Code CleanupsH - House LawnI - Intergalactic BiddingJ - Jumbled String B - Baby Bites 题目链接 答案 #include <iostream> #include<bits/stdc++.h> #define ll long long #define mem(a,b) memset(a,b,sizeof a) #define ull unsigned long long #define INF 0x3f3f3f3f3f3f3f3f #define rep(i,a,b) for(auto i=a;i<=b;++i) #define bep(i,a,b) for(auto i=a;i>=b;--i) #define lowbit(x) x&(-x) #...

AtCoder Beginner Contest 199(Sponsored by Panasonic) E - Permutation (状压dp)【代码】【图】

题意:一长度为\(n\)的序列,有\(m\)个限制条件,问有多少排列方法使得题目所给的\(m\)个限制条件都满足.题解:\(n\)给的范围很小,我们可以状态压缩,\(v[num][j]\)表示题目所给的限制条件前\(num\)个数最多不大于\(y\)的个数,我们可以枚举所有情况,然后判断每个状态是否和题目所给的条件冲突,如果冲突,我们就不转移.代码: #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #de...

[AT ZONe Energy Programming Contest] MAD TEAM【代码】

前言 这里有一个不太优秀但是很好打的做法。 先说时间复杂度:\(O(15*n^2)\)。如果想看更优时间复杂度,请移步木示木干的博客。 题目 AtCoder 题目大意: \(N\) 个人,每个人有五个能力值 \(A_i,B_i,C_i,D_i,E_i\),我们要从中选出三个人成为一个组,一个组中一种能力的能力值定义为所有人该种能力的最大值,一个组的能力值定义为该组五种能力值的最小值。 选出一个组使得其能力值最大并输出之。 \(3\le N \le 3000, 1\le A_i,B_i,...

Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)【代码】

Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2) 也就会写写模拟了 A - Sum of 2050 数位和 int main() {IOS;for (cin >> _; _; --_) {ll n, x; cin >> n;if (n % 2050) { cout << "-1\n"; continue; }x = n / 2050; n = 0;while (x) n += x % 10, x /= 10;cout << n << '\n';}return 0; }B - Morning Jogging int s[105][105], a[105][105], b[105], d[105];int main() {IOS;for (cin >> _; _; --_) {cin >> n >> m;re...

LeetCode Week Contest #235【代码】

LeetCode Week Contest #235 A. Truncate Sentence 思路简单,按空格作为单词的分隔符,返回前k个单词(注意包含空格) class Solution:def truncateSentence(self, s: str, k: int) -> str:return " ".join(s.split(' ')[:k])B. Find the Users Active Minutes 本题实际上是一个implementation的题,思路简单。 为了代码的简洁,可以使用map<int, set<int>>该数据结构进行讨论。 #define vt std::vector class Solution { public:...

300iq Contest 2【杂题】【代码】

传送门:link D Determinant 给定 \(n\) 个点 \(m\) 条边的简单连通无向图,求邻接矩阵行列式\(\bmod 998244353\)。 \(n\le 2.5\cdot 10^4\),\(m\le 5\cdot 10^5\),\(\exist k\in\{1,2,\cdots,25\}\),\(\forall A\subseteq V\land |A|=k+1\),\(\exist a,b\in A\),\(e\in E\),删去 \(e\) 之后 \(a,b\) 不连通。我们可以从题目条件推出这个图的双连通分量大小 \(\le k\)。 于是想到可以把双连通分量缩点,对这棵树搞树形 dp。 ...

2019-2020 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)【代码】

2019-2020 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) 文章目录 2019-2020 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)A Radio PrizeB Perfect FlushC Coloring ContentionD Dividing by TwoE Rainbow StringsI Error CorrectionJ Interstellar TravelK.Computer CacheL Carry Cam FailureM Maze ConnectA Radio Prize 大意: 求出一颗树上每个点到其他点的距离的和,两个点之间的距离定义为两个点的权值和...

LeetCode笔记:Biweekly Contest 49 比赛记录【代码】

LeetCode笔记:Biweekly Contest 49 0. 赛后总结1. 题目一 1. 解题思路2. 代码实现 2. 题目二 1. 解题思路2. 代码实现 3. 题目三 1. 解题思路2. 代码实现 4. 题目四 1. 解题思路2. 代码实现3. 算法优化 0. 赛后总结 表示人果然来是老了,中午和同学聚餐,跑去吃日料自助,兴致所至畅饮3大杯梅酒,然后直接就给跪了,当时没啥反应,吃完回来之后发现头晕脑涨,一觉睡到晚上快8点,回去之后还是晕乎乎的,饭都不怎么吃得下,硬塞了...

Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)【代码】

题目&题意:倒着找处于最后位置的等差数列的开头的位置。例:1 5 3 4 5 63 4 5 6是等差数列,它的开头的位置是3PS:读题真的很重要!!!!多组输入,上来就读错了!!代码:#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define FRE() freopen("in.txt","r",stdin) usingnamespace std; typedef longlong ll; constint maxn = 5e3+10; int dp[maxn][maxn]; int a[maxn];int main(){//FRE();int n;while(scanf("%d",&n)!=EOF)...