码迷,mamicode.com
首页 > 其他好文 > 详细

【BZOJ 4104】【Thu Summer Camp 2015】解密运算

时间:2016-08-14 22:07:26      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

http://www.lydsy.com/JudgeOnline/problem.php?id=4104

网上题解满天飞,我也懒得写了技术分享

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 200003;
int in() {
	int k = 0, fh = 1; char c = getchar();
	for(; c < ‘0‘ || c > ‘9‘; c = getchar())
		if (c == ‘-‘) fh = -1;
	for(; c >= ‘0‘ && c <= ‘9‘; c = getchar())
		k = (k << 3) + (k << 1) + c - ‘0‘;
	return k * fh;
}

struct node {
	int num, kth;
	bool operator < (const node &A) const {
		return num == A.num ? kth < A.kth : num < A.num;
	}
} Q[N];
int n, m;

int main() {
	n = in(); m = in();
	for(int i = 0; i <= n; ++i) Q[i].num = in(), Q[i].kth = i;
	
	sort(Q, Q + n + 1);
	
	int tmp = Q[0].kth;
	for(int i = 1; i <= n; ++i) printf("%d ", Q[tmp].num), tmp = Q[tmp].kth;
	
	puts("");
	return 0;
}

好虐心的一道题,看了一晚上QwQ技术分享

【BZOJ 4104】【Thu Summer Camp 2015】解密运算

标签:

原文地址:http://www.cnblogs.com/abclzr/p/5770998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!