CodeForces-12B-Correct Solution

原创 2016年05月31日 22:19:12

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;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

12B Correct Solution?

http://codeforces.com/contest/12/problem/B //cf 12B Correct Solution? /* 输入一个整数n(0 ≤ n ≤ 10^9)和m(0 ...

Codeforces 527B Error Correct System(字符串)

题意  两个长度为n的只由小写字母组成的字符串a.b  问能否同时交换两个串两个对应位置的字符  使得两个串相同位置字符不相同的数目最小 因为只能交换一次  所以只可能减少0,1或2个...
  • acvay
  • acvay
  • 2015年03月18日 19:49
  • 711

Codeforces 527 B Error Correct System 字母表

传送门:http://codeforces.com/contest/527/problem/B B. Error Correct System time limit per test 2...

【codeforces 527B】Error Correct System

【题目链接】:http://codeforces.com/contest/527/problem/B【题意】 给你两个字符串; 允许你交换一个字符串的两个字符一次; 问你这两个字符串最少会有...

Codeforces Round #296 (Div. 2B. Error Correct System

Ford Prefect got a job as a web developer for a small company that makes towels. His current work ta...

Codeforces Round #296 (Div. 2) - B. Error Correct System(脑洞)

题目: http://codeforces.com/contest/527/problem/B 题意: 给出两串n(1 ≤ n ≤ 200 000)个字母的字符串, 求出最多交换一对数, 使得不...

Codeforces 527B. Error Correct System【字符串】

B. Error Correct System time limit per test 2 seconds memory limit per test 256 megabyte...
  • wyjwyl
  • wyjwyl
  • 2016年04月21日 20:14
  • 142

codeforces 527b Error Correct System

题意:两个长度相同的字符串,最多给一次交换某一字符串两位置字母的机会,求出可得的两字符串的最小码距(即最少能有多少不相同的位置) 题解:因为最多进行一次交换,也就是说对于存在多种满足同样要求的交换情...

Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution 数论、易错

题意:找出多少组ai和aj 使 ai ^ aj == x. 数论、易错 ai ^ aj == x. => ai ^ x == aj 这样把sz[ai] 为数ai出现的次数,对于每个ai,a...

CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution

题意: 对于给定的nn个数字,要求找到这里面存在有几对数字对pair(a,b)pair(a,b),使得a⊕b=ma\oplus b=m. 发现数字范围是[0,100000][0,100000],所以,...
  • pootree
  • pootree
  • 2016年12月07日 14:48
  • 285
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CodeForces-12B-Correct Solution
举报原因:
原因补充:

(最多只允许输入30个字)