本文主要是介绍1001 Jump and Jump...,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1001 Jump and Jump...首先算出每个人的成绩,然后sort一下就好了,考虑n的范围只有2或者3,只要用if+swap也是可行的。/************************************************ Author: fisty* Created Time: 2015/1/24 19:02:10* File Name : BC_1.cpp*********************************************** */ #include <iostream> #include <cstring> #include <deque> #include <cmath> #include <queue> #include <stack> #include <list> #include <map> #include <set> #include <string> #include <vector> #include <cstdio> #include <bitset> #include <algorithm> using namespace std; #define Debug(x) cout << #x << " " << x <<endl const int INF = 0x3f3f3f3f; #define MAX_N 350 typedef long long LL; typedef pair<int, int> P; bool cmp(P e1, P e2){return e1.first > e2.first; } int main() {//freopen("in.txt", "r", stdin);int t;cin >> t;while(t--){int n;P arr[MAX_N];cin >> n;for(int i = 0;i < n; i++){int a, b, c;cin >> a >> b >> c;int d = max(a, max(b, c));arr[i].first = d;arr[i].second = i;}sort(arr, arr + n, cmp);for(int i = 0;i < n; i++){arr[arr[i].second].first = i+1;}for(int i = 0; i < n; i++){printf("%d%c",arr[i].first, i == n-1?'\n' : ' ');}}return 0; }
这篇关于1001 Jump and Jump...的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!