tc srm 636 div2 500
100的数据直接暴力就行,想多了。。。
ac的代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#define LL __int64
const int maxn = +;
using namespace std;
int a[maxn], sum; class SortishDiv2
{
public:
int ways(int sortedness, vector <int> seq)
{
int f[maxn], len, i, j, ans = ;
int cnt = , x[maxn];
len = seq.size();
memset(f, , sizeof(f));
for(i = ; i < len; i++)
f[seq[i]] = ;
for(i = ; i <= len; i++)
if(f[i]==)
x[cnt++] = i;
sort(x, x+cnt);
do
{
int y = ;
for(i = ; i < len; i++)
{
if(seq[i]==) a[i] = x[y++];
else a[i] = seq[i];
}
sum = ;
for(i = ; i < len; i++)
for(j = i+; j < len; j++)
if(a[j]>a[i])
sum ++;
if(sum == sortedness) ans ++;
}
while (next_permutation(x,x+cnt)); //数字的全排列 return ans;
}
}; /*int main()
{
SortishDiv2 s;
int i, j, n, y, tmp;
vector<int>v;
while(1)
{
v.clear();
cin>>n; cin>>y;
for(i = 0; i < y; i++)
{
cin>>tmp;
v.push_back(tmp);
}
cout<<s.ways(n, v)<<endl;
}
return 0;
}*/
tc srm 636 div2 500的更多相关文章
- TC SRM 664 div2 B BearPlaysDiv2 bfs
BearPlaysDiv2 Problem Statement Limak is a little bear who loves to play. Today he is playing by ...
- TC SRM 663 div2 B AABB 逆推
AABB Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description One day, Jamie noticed that many En ...
- TC SRM 663 div2 A ChessFloor 暴力
ChessFloor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description Samantha is renovating a squa ...
- TC SRM 665 DIV2 A LuckyXor 暴力
LuckyXorTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description A lucky number is a positive int ...
- TC SRM 584 DIV2
250pt: 水题set处理. 500pt: 题意: 给你一个图,每条边关联的两点为朋友,题目要求假设x的金钱为y,则他的左右的朋友当中的钱数z,取值为y - d <= z <= y + ...
- TC SRM 593 DIV2 1000
很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...
- TC SRM 591 DIV2 1000
很不错的一题,非常巧妙的用DP顺序解决这个问题... 可以发现,只和A里面最小的有关系... #include <cstdio> #include <cstring> #inc ...
- 求拓扑排序的数量,例题 topcoder srm 654 div2 500
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are number ...
- Topcoder SRM 619 DIv2 500 --又是耻辱的一题
这题明明是一个简单的类似约瑟夫环的问题,但是由于细节问题迟迟不能得到正确结果,结果比赛完几分钟才改对..耻辱. 代码: #include <iostream> #include <c ...
随机推荐
- CSS3实现的渐变按钮,在IE7、IE6下的滤镜使用。
.ui-button { BORDER-LEFT-WIDTH:; ; COLOR: #fff; PADDING-BOTTOM: 0px; TEXT-ALIGN: center; PADDING-T ...
- 上海9000辆出租车上铺设免费微信连WiFi
据了解,去年7月,2000辆贴有Wi-Fi标识的上海大众出租车已经正式上路.近期,为了加大方便市民的力度,上海云联将上海大众等9000辆出租车上铺设免费微信连WiFi,为上海乘客提供简单便捷的微信连W ...
- MYSQL注入天书之数据库增删改介绍
Background-4 增删改函数介绍 在对数据进行处理上,我们经常用到的是增删查改.接下来我们讲解一下mysql 的增删改.查就是我们上述总用到的select,这里就介绍了. 增加一行数据.Ins ...
- JSP 页面传参和接受参数
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding=&q ...
- KMP高质量代码实现详解
KMP算法 对于KMP算法我分为两个部分说明,第一部分是算法部分,介绍KMP算法的算法思想:第二部分是实现部分,介绍一种厉害的实现代码以及代码注释.当然了由于本文主要介绍怎么实现故而先分析实现,对KM ...
- JAVA动态加载JAR包的实现
如何动态的加载这些驱动!不可能把所有的数据库驱动都集成到JAR包中吧?!于是动态加载驱动的JAR包就产生了!其实这些在做系统基础代码时,经常用到,只是一般我们没有机会去搞而已. 动态加载JAR包,使用 ...
- 14.spark RDD解密
开篇:spark各种库,sparksql,sparkmachicelearning,等这么多库底层都是封装的RDD.意味着 1:RDD本身提供了通用的抽象, 2:spark现在有5个子框架,sql,S ...
- 基于Eclipse的scala应用开发
原创文章,转载请注明: 转载自www.cnblogs.com/tovin/p/3823968.html 为了更好的学习scala语言,本文介绍如何基于Maven来构建scala项目 1.首先参照www ...
- hive-学习笔记
1.hive模糊搜索表 show tables like '*name*'; 2.查看表结构信息 desc formatted table_name; desc table_name; 3.查看 ...
- Java中使用验证码和二维码
资源 需要: jelly-core-1.7.0.GA.jar 网站: http://lychie.github.io/products.html 将下载下来的 jelly-core-1.7.0 ...