版本号排序

不知道什么傻逼原因,就是过不了

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
void makedata() {
    freopen("input.txt", "w", stdout);
    cout << 200000 << endl;

    for(int i = 0; i < 200000; i++) cout << 1000000000 << ' ';

    fclose(stdout);
}

VI a[200];
bool ok(int x, int y) {
    int lx = a[x].size(), ly = a[y].size();
    int l = min(lx, ly);

    for(int i = 0; i < l; i++) {
        if(a[x][i] < a[y][i]) return true;

        if(a[x][i] > a[y][i]) return false;
    }

    if(lx <= ly) return true;
    else return false;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a[i].push_back(tmp);

        while(getchar() == '.') {
            cin >> tmp;
            a[i].push_back(tmp);
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(!ok(i, j)) swap(a[i], a[j]);
        }
    }

    for(int i = 0; i < n; i++) {
        cout << a[i][0];

        for(int j = 1; j < a[i].size(); j++) cout << '.' << a[i][j];

        cout << endl;
    }

    return 0;
}
View Code

相关文章: