关闭

CodeForces-12B-Correct Solution

206人阅读 评论(0) 收藏 举报
分类:

Description

One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice’s turn, she told the number n to Bob and said:

—Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.

—No problem! — said Bob and immediately gave her an answer.

Alice said a random number, so she doesn’t know whether Bob’s answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.

Input

The first line contains one integer n (0 ≤ n ≤ 109) without leading zeroes. The second lines contains one integer m (0 ≤ m ≤ 109) — Bob’s answer, possibly with leading zeroes.

Output

Print OK if Bob’s answer is correct and WRONG_ANSWER otherwise.

Sample Input
Input

3310
1033

Output

OK

Input

4
5

Output

WRONG_ANSWER
sort一下之后直接找第一个0和第一个非0就OK了

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[10010];
char b[10010], c[1010], d[1010];
int main() {
    while (scanf("%s%s", a, b) != EOF) {
            int len = strlen(a);
    sort(a, a + len);
    int flag = 0;
    for (int i = 0; i < len; i++) {
            if (a[i] != '0') {
                flag = i;
    char t = a[i];
    a[i] = a[0];
    a[0] = t;
    break;
    }
    }
    if (strcmp(a, b) == 0) {
            printf("OK\n");
    }
    else
        {
            printf("WRONG_ANSWER\n");
            }
}
return 0;
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:61404次
    • 积分:4132
    • 等级:
    • 排名:第7754名
    • 原创:370篇
    • 转载:1篇
    • 译文:0篇
    • 评论:2条
    最新评论