【AtCoder ABC 075 C】Bridge】的更多相关文章

[链接] 我是链接,点我呀:) [题意] 让你求出桥的个数 [题解] 删掉这条边,然后看看1能不能到达其他所有的点就可以了 [代码] #include <bits/stdc++.h> using namespace std; const int M = 50; int n, m,g[M+10][M+10]; pair<int, int> a[M+10]; bool bo[M + 10]; void dfs(int x) { if (bo[x]) return; bo[x] = tr…
[链接] 我是链接,点我呀:) [题意] 让你找到一个各边和坐标轴平行的矩形.使得这个矩形包含至少K个点. 且这个矩形的面积最小. [题解] 把所有的"关键点""都找出来. 然后枚举任意两个点作为矩形的对角. 然后看他是不是包含了至少K个点即可. [代码] #include <bits/stdc++.h> using namespace std; const int N = 50; int n, k; long long ans = -1; int xx[N +…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟,把#换成1 八个方向加一下就好. [代码] #include <bits/stdc++.h> using namespace std; const int N = 50; const int dx[8] = { 1,1,1,0,0,-1,-1,-1 }; const int dy[8] = { -1,0,1,-1,1,-1,0,1 }; int a[N + 10][N + 10],h,w; string s; int m…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map轻松搞定 [代码] #include <bits/stdc++.h> using namespace std; map <int, int> mmap; int main() { for (int i = 0; i < 3; i++) { int x; scanf("%d", &x); mmap[x]++; } for (auto y : mmap) if (y.secon…
[链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错的次数] 0 [反思] 在这了写反思 [代码] #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <vector> #incl…
Atcoder hbpc C 题意:给n个循环小数或者有限小数,问其中有多少个互不相同的. 思路:我的思路比较繁琐. 首先我们考虑分数化小数:假设原来的数是\(a.b(c)\),那么这个分数就是\(a+\frac{b}{10^{len_b}}+\frac{c}{10^{len_b}\times (10^{len_c}-1)}\). 所以用4哈希判一下两个是否相同,需要注意我们的哈希模数必须都要取质数,因为需要取\(10^{\dots}\).\(10^{\dots}-1\)的逆元. 这里我取的是\…
题目描述 穿越了森林,前方有一座独木桥,连接着过往和未来(连接着上一题和下一题...). 这座桥无限长. 小 Q 在独木桥上彷徨了.他知道,他只剩下了 N 秒的时间,每一秒的时间里,他会向 左或向右移动一步. N 秒之后,小 Q 恰在桥上某一特定位置,且他每两次经过此位置的时间间隔不会超过 M 秒. 那么问题来了,这 N 秒的时间里,小 Q 的路线总共会有多少种可能的形式. 输入 文件第一行两个正整数 N.M,如题目所描述 输出 输出一个整数,表示可能的路线数量最终模 1000000007 的结…
Young Maids Time Limit: 50 Sec  Memory Limit: 512 MB Description 给定一个排列,每次选出相邻的两个放在队头,要求字典序最小. Input 第一行一个整数n,第二行n个数表示这个排列. Output n个数表示答案. Sample Input 8 4 6 3 2 8 5 7 1 Sample Output 3 1 2 7 4 6 8 5 HINT n%2=0,2 <= n <= 2e5 Solution 倒着考虑. 我们维护一个小根…
Shik and Travel Time Limit: 50 Sec  Memory Limit: 512 MB Description 给定一棵n个点的树,保证一个点出度为2/0. 遍历一遍,要求每条边被经过两次,第一次从根出发,最后一次到根结束,在叶子节点之间移动. 移动一次的费用为路径上的边权之和,第一次和最后一次免费,移动的最大费用 最小可以是多少. Input 第一行一个n,表示点数. 之后两个数x, y,若在第 i 行,表示 i+1 -> x 有一条权值为 y 的边. Output…
Wide Swap Time Limit: 50 Sec  Memory Limit: 512 MB Description Input Output Sample Input 8 3 4 5 7 8 3 1 2 6 Sample Output 1 2 6 7 5 3 4 8 HINT Solution 首先,直接做难度系数较高,假设原序列为a,我们考虑设一个p,p[a_i] = i,即将题目中的权值与下标调换. 那么显然,要令a字典序最小,只要让p字典序最小即可.因为“权值小的尽量前”与“前面…