#686 div3

http://codeforces.com/contest/1454

A. Special Permutation

consisting 组成
distinct 不同的
condition 条件
proven 证明

找到一个1~n的全排列,使每个数不等于它的下标

	int t;
	cin >> t;
	while(t --) {
		int n;
		cin >> n;
		for(int i = 2; i <= n; i ++) {
			cout << i << " ";
		}
		cout << 1 << endl;
	}

B. Unique Bid Auction

Unique 独一无二的
Bid 投标竞价
Auction 拍卖
minimal 最小

    int t;
    cin >> t;
    while(t --) {
    	int n;
    	cin >> n;
    	map<int, int> mp;
    	int a[200005];
    	mp.clear();
    	for(int i = 1; i <= n; i ++) {
    		cin >> a[i];
    		mp[a[i]] ++;
		}
		int ans = 1e9, ii = -1;
		for(int i = 1; i <= n; i ++) {
			if(mp[a[i]] == 1 && a[i] < ans) 
				ans = a[i], ii = i;
		}
		cout << ii << endl;
	}

C. Sequence Transformation *

segment 段
contiguous 相邻的
collapses 崩溃 折叠

学习:INT_MAXINT_MIN直接赋最大最小值

void solve() {
	int n;
	cin >> n;
	int a[n], ans = INT_MAX;
	map<int, int> mp;
	for(int i = 0; i < n; i ++) {
		cin >> a[i];
		if(i == 0) continue;
		else if(a[i] != a[i - 1]) mp[a[i]] ++;
	}
	mp[a[n - 1]] --; //*
	for(int i = 0; i <n; i ++) {
		ans = min(ans, mp[a[i]]);
	}
	cout << ans + 1 << endl;
}

D. Number into Sequence

Sequence 序列
strictly 严格的

上一篇:Java实现 LeetCode 686 重复叠加字符串匹配


下一篇:Scipy优化算法--scipy.optimize.fmin_tnc()/minimize()