A题: #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <queue> #include <math.h> using namespace std; typedef long long LL; const int MAX=100010; int n,m; int a[MAX],b[MAX]; int mai…
这题真的有毒 首先你忽略 N-M < 100 的条件你就gg吧 其次就算你知道了怎么做之后 还有可能因为写vector或者各种常数大的原因被卡 #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<map> #include<cmath> #include<cstring> #include<queue…
题目要求写一个直接用比较排序的pascal程序,挺有趣的一题. 我看题目数据范围就到8,本来以为贪个小便宜,用switch输出. 然后发现比较次数是阶乘级别的,8的阶乘也是挺大的,恐怕会交不上去. 于是改用回溯法. 其实他比较时就是把后面的数一个一个向前比较,然后插到那位前面,继续回溯. else的处理比较麻烦而已,改了好久终于跟标准答案一样了. 缩进没有处理,提交上去就ac了,看来oj没有检查缩进呢,如果有检查就还得处理一下了. 代码:(未进行缩进处理) #include <cstdio>…
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the prese…
A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in…
原题与此题 原题是一道神仙不可做题,两者区别在于,原题不能有重边和自环. 然而,这题可以有重边... 于是这题就变成了一道大水题. 此题的解法 考虑如何构造. 对于\(n\le10^4\)的情况: 对于\(n>10^4\)的情况: 边上的权值表示边数. 代码 #pragma GCC optimize(2) #include<bits/stdc++.h> #define Tp template<typename Ty> #define Ts template<typena…
2016湖南省赛----G - Parenthesis (括号匹配)   Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th question is whether P remains balanced after p ai and p bi  swapped. Note that questions are individual so that they hav…
2016湖南省赛----A 2016 (同余定理) Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤10 9). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000000000 Sample…
2016湖南省赛 I Tree Intersection(线段树合并,树链剖分) 传送门:https://ac.nowcoder.com/acm/contest/1112/I 题意: 给你一个n个结点的树,树上每个节点有自己的颜色 问你删除第i条边后形成的两颗子树有多少个相同的颜色 题解: 树链剖分写法: 对于每一种颜色来说,如果这个颜色是在单独的一颗子树中,那么就不会对其他的边产生贡献,所以我们单独对每一种颜色对边的贡献讨论,如果这个颜色只有一个,那么就不会产生贡献,否则,他就可以在两个相同颜…
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[Submit][Status][Web Board] Description 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换. Input 一个3x3的矩阵 Output 转置后的矩阵 Sample Input 1 2 3 4 5 6 7 8 9 Sample Output 1 4 7…