Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

暴力简洁0ms

Posted by 416221843 at 2016-11-17 14:17:14 on Problem 1007
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{char a[105][55];
	int i, j, k, x[105] = { 0 }, x1[105] = {0}, m, n;
	scanf("%d%d",&n,&m);
	for (i = 0; i < m; i++)
		scanf("%s",a[i]);
	for (i = 0; i < m; i++)
		for (j = 0; j < n - 1; j++)
			for (k = j + 1; k < n; k++)
				if (a[i][k] < a[i][j]) x[i]++,x1[i]++;
	sort(x, x + m);
	for (i = 0; i < m; i++)
		for (j = 0; j < m; j++)
			if (x[i] == x1[j]) { printf("%s\n", a[j]); x1[j] = -1; break; }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator