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...
最新推荐文章于 2023-04-25 16:19:45 发布