LA uvalive 7370 Classy (sort, compare)

Source: Internet
Author: User

Test instructions: Given n individuals, and their number is compared, starting from behind, if not long enough, add middle then than, until not, if the same than the name.

Analysis: The problem of water, it is needless to say.

The code is as follows:

#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < functional> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring># Include <set> #include <queue> #include <algorithm> #include <vector> #include <deque># Include <map> #include <cctype> #include <stack> #include <sstream>using namespace std; typedef  Long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1e3 + 5;const int mod = 1e9 + 7;const char *mark = "+-*"; const INT DR  [] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};int N, m;inline bool is_in (int r, int c) {return R >= 0 && R < n && C >= 0 && C < m;} inline int Min (int a, int b) {return a < b a:b;} inline int Max (int a, int b) {return a > b a:b;}    struct node{string S; Vector<int> v;};    Node a[maxn];string s;bool CMP (const node &AMP;LHS, const node &AMP;RHS) {int i = lhs.v.size ()-1, J = rhs.v.size ()-1; while (true) {if (i >= 0 && J >= 0) {if (Lhs.v[i]! = Rhs.v[j]) return lhs.v[i] > rhs.v[        J];        } else if (I >= 0) {if (lhs.v[i]! = 1) return lhs.v[i] > 1;        } else if (J >= 0) {if (rhs.v[j]! = 1) return rhs.v[j] < 1;        }--------j;    if (I < 0 && J < 0) break; } return LHS.S < RHS.S;}            int main () {while (scanf ("%d", &n) = = 1) {for (int i = 0; i < n; ++i) {a[i].v.clear ();  Cin >> A[i].s;            A[i].s.pop_back ();                while (Cin >> s && s[0]! = ' C ') {if (s[0] = = ' u ') a[i].v.push_back (2);                else if (s[0] = = ' m ') a[i].v.push_back (1);            else A[i].v.push_back (0);       }} sort (A, a+n, CMP); for (int i = 0; i < n; ++i) cout << a[i].s << Endl; } return 0;}

  

LA uvalive 7370 Classy (sort, compare)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.