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 ... 
随机推荐
- frequentism-and-bayesianism-chs-iv
			frequentism-and-bayesianism-chs-iv 频率主义与贝叶斯主义 IV:Python的贝叶斯工具 这个notebook出自Pythonic Perambulations的 ... 
- .Net 执行 Oracle SQL语句时, 中文变问号
			带中文的Sql语句在.Net调用时, 中文变问号(可使用 SQL Tracker工具跟踪) 问题: 服务器的字符集与客户端的字符集不一致. 解决方法: 1. 查看服务端的字符集: ... 
- <context:annotation-config> 跟 <context:component-scan>诠释及区别
			<context:annotation-config> 是用于激活那些已经在spring容器里注册过的bean(无论是通过xml的方式还是通过package sanning的方式)上面的注 ... 
- iOS 面试题
			1.Object-c的类可以多重继承么?可以实现多个接口么?Category是什么?重写一个类的方式用继承好还是分类好?为什么? 答:不可以,可以实现多个接口:category是分类,,一般情况下分类 ... 
- HDOJ 1398 Square Coins 母函数
			Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ... 
- “System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常。{转}
			<connectionStrings> <add name="ConnectionStringName" providerName="System.Da ... 
- Python编程指南 chapter 1
			1.python使用方括号[]来存取一个序列中的某个数据项,像字符串.列表等包含若干数据项的序列都采用这种方法. 2.强制类型转换,int('24234'),str(235) 3.python中没有变 ... 
- 利用dsniff的tcpkill杀TCP连接
			利用dsniff的tcpkill杀TCP连接 Linux连接久久不能释放的现象不常见,但偶然也会发生.进程虽不复存在,但是客户端的连接咬定青山不放松,死活也不肯吐出连接,导致重启进程时因操作系统判断监 ... 
- shell如何自动输入密码
			shell如何自动输入密码 http://linux.ctocio.com.cn/171/12162171.shtml 
- (3)初次接触off
			boss布置任务了,要读入off文件,生成能显示出来的可执行文件,完成不了就要滚蛋 目前的东西还是不用保密的,到后面我就要设密码了 好,.off文件是什么? OFF,Object File Forma ... 
