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 ...
随机推荐
- php中==与===区别
==是不判断二者是否是同一数据类型,而===是更为严格的比较,它不但要求二者值相等,而且还要求它们的数据类型也相同
- Javascript动态生成表格的性能调优
vision 0.8 [耗时672ms]终极优化 将字符串作为数组对象的方式是目前效率最高,性能最优的方式. <script> var t1 = new Date(); < ...
- JavaScript之四种继承方式讲解
在Javascript中,所有开发者定义的类都可以作为基类,但出于安全性考虑,本地类和宿主类不能作为基类,这样可以防止公用访问编译过的浏览器级的代码,因为这些代码可以被用于恶意攻击. 选定基类后,就可 ...
- 谈谈arm下的函数栈
引言 这篇文章简要说说函数是怎么传入参数的,我们都知道,当一个函数调用使用少量参数(ARM上是少于等于4个)时,参数是通过寄存器进行传值(ARM上是通过r0,r1,r2,r3),而当参数多于4个时,会 ...
- Unity上使用Linq To XML
using UnityEngine; using System.Collections; using System.Linq; using System.Xml.Linq; using System; ...
- Guava官方文档-RateLimiter类
转载自并发编程网 – ifeve.com RateLimiter 从概念上来讲,速率限制器会在可配置的速率下分配许可证.如果必要的话,每个acquire() 会阻塞当前线程直到许可证可用后获取该许可证 ...
- 深入浅出ES6(十七):展望未来
作者 Jason Orendorff github主页 https://github.com/jorendorff 出于对文章长度的考虑,我们还保留了一些尚未提及的新特性,在最后的这篇文章中我会集 ...
- C Primer Plus之结构和其他数据形式
声明和初始化结构指针 声明结构化指针,例如: struct guy * him; 初始化结构指针(如果barney是一个guy类型的结构),例如: him = &barney; 注意:和数组不 ...
- C 和C++ 名称修饰规则
C名称修饰规则 1.对于使用__cdecl调用约定的函数,在函数名称前加一下划线,不考虑参数和返回值. 2.对于使用__fastcall调用约定的函数,在函数名称前后各加一@符号,后跟参数的长度,不考 ...
- __stdcall 与 __cdecl
(1) _stdcall调用 _stdcall是Pascal程序的缺省调用方式,参数采用从右到左的压栈方式,被调函数自身在返回前清空堆栈. WIN32 Api都采用_stdcall调用方式,这样的宏定 ...