Luo Gu P3742 umi function

Portal

Thinking

\ (loceaner \) already CaiVirtual KunTo even the red title will not do

Because there \ (special \ judge \) so we can fiddle up!

From the title, as long as there is a \ (y [i]> x [i] \) is no certain answer (apparently a really!), Other words, because \ (y \) is itself a solution, so final output \ (y \) just fine, but I started to brain damage ...... therefore a useful intermediary array ...... but too lazy to change, anyway, able to live ( data water Well )

Code

//知识点:
/*
By:Loceaner
*/
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

const int N = 111;

int n;
char x[N], y[N], zj[N];

int main() {
    n = read();
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n; i++) cin >> y[i];
    for(int i = 0; i < n; i++) {
        if((int)x[i] < int(y[i])) return cout << "-1\n", 0;
        else if((int)x[i] == (int)y[i]) zj[i] = x[i];
        else if((int)x[i] > (int)y[i]) zj[i] = y[i];
    }
    for(int i = 0; i < n; i++) cout << zj[i];
    return 0;
}

Guess you like

Origin www.cnblogs.com/loceaner/p/11689851.html