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?

B. Correct Solution? time limit per test 2 seconds memory limit per test 256 megabytes ...
  • liuke19950717
  • liuke19950717
  • 2016年07月21日 09:57
  • 312

cf12B

http://codeforces.com/problemset/problem/12/B B. Correct Solution? time limit per test 2 sec...
  • lanjiangzhou
  • lanjiangzhou
  • 2013年05月30日 11:20
  • 519

CodeForces 12B - Correct Solution?

我想到的是把输入输出看作是字符串,然后用sort排序,当排序后,若第一个字符为‘0’,则在后面找到第一个非零的数,然后把它交换下就行了!总的来说这道题目应该比较简单的啦#include #inclu...
  • MrSiz
  • MrSiz
  • 2015年09月17日 19:17
  • 489

CodeForces 527B Error Correct System

B. Error Correct System time limit per test 2 seconds memory limit per test 256 megabyte...
  • lizhaowei213
  • lizhaowei213
  • 2016年01月17日 14:25
  • 147

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

B. Error Correct System time limit per test 2 seconds memory limit per test 256 megabyte...
  • wust_ZJX
  • wust_ZJX
  • 2015年03月18日 10:32
  • 868

【Codeforces Round 335 (Div 2) B】【模拟】Testing Robots 机器人逐步走 走到矿场就爆炸的最多行走步数

B. Testing Robots time limit per test 2 seconds memory limit per test 256 megabytes ...
  • snowy_smile
  • snowy_smile
  • 2015年12月10日 13:43
  • 753

codeforces 12B - Correct Solution?

细心即可 #include #include #include #include #include #include #include #include #inclu...
  • ymrfzr
  • ymrfzr
  • 2013年06月05日 07:38
  • 699

Codeforces Testing Round #12 B - Restaurant ( 贪心 )

题目链接 题意:给出n个不相交的区间,求出不相交区间的最大个数 解答:先按照区间右断点排序,再按照区间左端点排序 #include using namespace std; #define LL ...
  • u013167299
  • u013167299
  • 2015年11月12日 15:51
  • 275

CodeForces-12B-Correct Solution

DescriptionOne cold winter evening Alice and her older brother Bob was sitting at home near the fire...
  • Ypopstar
  • Ypopstar
  • 2016年05月31日 22:19
  • 294

Codeforces 527 B Error Correct System 字母表

传送门:http://codeforces.com/contest/527/problem/B B. Error Correct System time limit per test 2...
  • haoliang94
  • haoliang94
  • 2015年03月19日 13:26
  • 585
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CodeForces-12B-Correct Solution
举报原因:
原因补充:

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