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 ...
随机推荐
- CrowdFlower Winner's Interview: 1st place, Chenglong Chen
CrowdFlower Winner's Interview: 1st place, Chenglong Chen The Crowdflower Search Results Relevance c ...
- asp.net各种类型视频播放代码(全)
1.avi格式 代码片断如下: <object id="video" width="400" height="200" border= ...
- c3p0 --1
# # This file is detritus from various testing attempts # the values below may change, and often do ...
- Docker 面临的安全隐患,我们该如何应对
[编者按]对比虚拟机,Docker 在体量等方面拥有显著的优势.然而,当 DevOps 享受 Docker 带来扩展性.资源利用率和弹性提升的同时,其所面临的安全隐患同样值得重视,近日 Chris T ...
- isMobile 一个简单的JS库,用来检测移动设备
点这里 github地址:https://github.com/kaimallea/isMobile Example Usage I include the minified version of t ...
- asp.net网站中添加百度地图功能
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
- Jquery 中map和each的区别
<script type="text/javascript"> $(function () { var json = {"Name":"L ...
- Android中的SQLite使用学习
Android中的SQLite使用学习 SQLite是非常流行的嵌入式关系型数据库,轻载, 速度快,而且是开源.在Android中,runtime提供SQLite,所以我们可以使用SQLite,而且是 ...
- Tomcat内存溢出(java.lang.OutOfMemoryError: PermGen space)的解决办法
Tomcat启动时报如下错误: java.lang.OutOfMemoryError: PermGen space 解决办法: 配置相关内存大小.其中按照启动tomcat的不同方式,分如下三种情况 a ...
- Visual Studio 项目中添加include, lib, dll库文件(*.h,*.lib,*.dll)
应用程序使用外部库时需要进行加载,两种库的加载本质上都是一样:提供功能和功能的定义.vs2005 c++ 项目设置外部库方法如下: 1. 添加编译所需要(依赖)的 lib 文件 在“项目-&g ...