zoj 3914 Semantic Version(模拟)

33 篇文章 0 订阅
22 篇文章 0 订阅

题目链接:zoj 3914 Semantic Version

代码

#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
const int maxn = 100;

int P, N;
char a[maxn], b[maxn];
vector<string> A, B;

bool ischar(char ch) {
    if (ch >= 'a' && ch <= 'z') return true;
    if (ch >= 'A' && ch <= 'Z') return true;
    return false;
}
bool isnumber(char ch) { return ch >= '0' && ch <= '9'; }
void match(char c, char* s) { if (P < N && s[P] == c) P++; }
int getNumber (char* s) {
    int u = 0;
    while (P < N && isnumber(s[P]))
        u = u * 10 + s[P++] - '0';
    return u;
}

string get (char* s) {
    string ret = "";
    while (P < N && s[P] != '.' && s[P] != '-')
        ret = ret + s[P++];
    return ret;
}

void solve (vector<string>& u, char* s) {
    u.clear();
    P = 0;
    N = strlen(s);

    while (P < N) {
        u.push_back(get(s));
        if (s[P] == '.' || s[P] == '-') P++;
    }
}

int change(string& u) {
    int ret = 0;
    for (int i = 0; i < u.length(); i++)
        ret = ret * 10 + (u[i]-'0');
    return ret;
}

bool judge () {
    for (int i = 0; i < A.size() || i < B.size(); i++) {
        if (i >= A.size()) return i != 3;
        if (i >= B.size()) return i == 3;

        if (isnumber(A[i][0]) && isnumber(B[i][0])) {
            int tmpa = change(A[i]), tmpb = change(B[i]);
            if (tmpa != tmpb) return tmpa < tmpb;
        } else if (A[i] != B[i]) return A[i] < B[i];
    }
    return false;
}

int main () {
    while (scanf("%s%s", a, b) == 2) {
        solve(A, a);
        solve(B, b);
        printf("%s\n", judge() ? "Wow! Such feature! Very smart! I'm excited!" : "I'm angry!");
    }
    return 0;
}
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值