【Link】:

【Description】



给你n个数字组成原数列;

然后,让你生成n个新的数列a

其中第i个数列ai为删掉原数列中第i个数字后剩余的数字组成的数列;

然后问你这n个数列组成的排序数组(即按照把第i个位置上的数改为第i大的数在未改变之前数组中的位置这个规则转化成的数组);

有多少种不同类型

【Solution】



首先,枚举第i个数字被删掉了;

然后用结构体来存剩下的n-1个数字形成的数组,

(存数值下标)

然后排序,获取第i大的数的下标;

存到vector里面,用map< vector < int >,int>来判重;



【NumberOf WA】



0



【Reviw】



map判重很方便。

遇到要知道下标的,一般都用结构体排序吧;



【Code】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
//head
struct abc{
int x,id;
};
abc a[N];
map <vector <int>,int > dic; bool cmp(abc a,abc b){
return a.x > b.x;
} class RelativeHeights
{
public:
int countWays(vector <int> h)
{
int ans = 0;
dic.clear();
int len = h.size(),n;
vector <int> v;
rep1(i,0,len-1){
n = 0;
rep1(j,0,len-1)
if (i!=j){
n++;
a[n].id = n-1,a[n].x = h[j];
}
sort(a+1,a+1+n,cmp);
v.clear();
rep1(j,1,n){
v.pb(a[j].id);
}
if (!dic[v]){
ans++;
dic[v] = 1;
}
}
return ans;
}
};

【TC SRM 718 DIV 2 A】RelativeHeights的更多相关文章

  1. 【TC SRM 718 DIV 2 B】Reconstruct Graph

    [Link]: [Description] 给你两个括号序列; 让你把这两个括号序列合并起来 (得按顺序合并) 使得组成的新的序列为合法序列; 即每个括号都能匹配; 问有多少种合并的方法; [Solu ...

  2. 【topcoder SRM 702 DIV 2 250】TestTaking

    Problem Statement Recently, Alice had to take a test. The test consisted of a sequence of true/false ...

  3. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  4. 【SRM 716 DIV 1 A】 ConstructLCS

    Problem Statement A string S is a subsequence of a string T if we can obtain S from T by erasing som ...

  5. 【Codeforces Round #434 (Div. 1) B】Polycarp's phone book

    [链接]h在这里写链接 [题意] 给你n个电话号码. 让你给每一个电话号码选定一个字符串s; 使得这个串s是这个电话号码的子串. 且不是任何一个其他电话号码的子串. s要求最短. [题解] 字典树. ...

  6. 【Codeforces Round #493 (Div. 2) B】Cutting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  7. 【Codeforces Round #499 (Div. 1) B】Rocket

    [链接] 我是链接,点我呀:) [题意] 让你猜到火星的距离x是多少. 已知1<=x<=m 然后你可以问系统最多60个问题 问题的形式以一个整数y表示 然后系统会回答你3种结果 -1 x& ...

  8. 【Codeforces Round #499 (Div. 2) E】Border

    [链接] 我是链接,点我呀:) [题意] 给你n个数字,每个数字可以无限用,每种方案可以组成一个和,问你%k的结果有多少种不同的结果. [题解] 相当于给你一个方程 \(x_1*a_1+x_2*a_2 ...

  9. 【Codeforces Round #483 (Div. 2) C】Finite or not?

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 有个性质. 如果p/q是分数的最简形式. 那么p/q能化成有限小数. 当且仅当q的质因数分解形式中只有质因子2和5 (且不能出现其他 ...

随机推荐

  1. BNUOJ34980方(芳)格(哥)取数(好坑)

    方(芳)格(哥)取数 Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class n ...

  2. Sqlite3的安装Windows

  3. SecondaryNameNode合并元信息过程

  4. [ Java ] [ Eclipse ] content Auto activation triggers

    重點: That plug-in is not necessary any more. Just go to Preferences > Java > Editor > Conten ...

  5. Blink Coordinate Spaces

    Blink Coordinate Spaces Blink Coordinate Spaces Types of Zoom There are two types of zoom in Chromiu ...

  6. tgtadm和iscsiadm命令的用法

    一.tgtadm命令 tgtadm常用于管理三类对象:     target:创建new,删除,查看     lun:创建,查看,删除     account:创建用户,绑定,解绑定,删除,查看 语法 ...

  7. 大数问题(相加) A + B

    I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum o ...

  8. screen---管理会话

    Screen是一款由GNU计划开发的用于命令行终端切换的自由软件.用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换.GNU Screen可以看作是窗口管理器的命令行界面版本.它提 ...

  9. Java.Lang.NoSuchMethod 错误

    项目开发.调用webservice,方法调用报了 Java.Lang.NoSucheMethod..........,印象中记得是jar包冲突,maven项目,一看,这一堆jar包...用eclips ...

  10. [Python] Use a Python Generator to Crawl the Star Wars API

    In this lesson, you will be introduced to Python generators. You will see how a generator can replac ...