C 用scanf("%s")就会WA..不知道为什么 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; ][] = {{, }, {, }, {, -}, { -, }, {, }, {,…
(https://atcoder.jp/contests/abc134/tasks/abc134_e) 题意:找出最小个数的最长上升子序列 思路:找出最长上升子序列的最小个数,只需要找出每个最小上升子序列的最后一个元素,然后元素个数之和就是最长上升子序列的最小个数 #include <iostream> #include<set> #include<cstdio> #include<algorithm> using namespace std; ; int…
https://atcoder.jp/contests/arc085/tasks/arc085_c 题目大意 略 解法 最小割即可. 直接建图有负边,但是因为我们知道最后在割上的边数一定为 \(N\) 条,此时只需要对边权加上一个偏移量做最小割,最后减去偏移量带来的额外消耗即可.…
E - Knapsack 2 Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement There are NN items, numbered 1,2,…,N1,2,…,N. For each ii (1≤i≤N1≤i≤N), Item ii has a weight of wiwi and a value of vivi. Taro has decided to choose some…
题目链接:https://atcoder.jp/contests/abc121/tasks/abc121_d 题目很裸(Atcoder好像都比较裸 就给一个区间求异或和 n到1e12 肯定不能O(n)推 那肯定得通过异或的一些性质 用$f\left( a,b\right)$表示[a,b]区间的异或和 我只观察出了$f\left( 2^{a},2^{b}-1\right)$的异或和肯定为0. 通过$f\left( 2^{a},2^{a+1}-1\right)$每一位都会出现偶数次 例如 [4,8)…
题目链接:https://atcoder.jp/contests/abc120/tasks/abc120_d 题意 先给m条边,然后按顺序慢慢删掉边,求每一次删掉之后有多少对(i,j)不连通(我应该解释对了吧) 删边这个过程就可以从反方向进行,相当于从m到1慢慢加边 然后就把连通的用并查集存起来,另用一个s数组来存每个点和他连通的有几个点 不连通的就减去s[i]*s[j]就好了 初始的是C(n,2) 没边的时候所有点都不连通嘛. 代码如下 #include <cstdio> #include…
D - Knapsack 1 Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement There are NN items, numbered 1,2,…,N1,2,…,N. For each ii (1≤i≤N1≤i≤N), Item ii has a weight of wiwi and a value of vivi. Taro has decided to choose some…
B - Frog 2 Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement There are NN stones, numbered 1,2,…,N1,2,…,N. For each ii (1≤i≤N1≤i≤N), the height of Stone ii is hihi. There is a frog who is initially on Stone 11. He will…
A - Frog 1 Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement There are NN stones, numbered 1,2,…,N1,2,…,N. For each ii (1≤i≤N1≤i≤N), the height of Stone ii is hihi. There is a frog who is initially on Stone 11. He will…
https://atcoder.jp/contests/agc031/tasks/agc031_b B - Reversi Time Limit: 2 sec / Memory Limit: 1024 MB Problem Statement There are N stones arranged in a row. The i-th stone from the left is painted in the color Ci. Snuke will perform the following…