• B. Colourblindness


    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    Vasya has a grid with 22 rows and nn columns. He colours each cell red, green, or blue.

    Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.

    Input

    The input consists of multiple test cases. The first line contains an integer tt (1≤t≤1001≤t≤100) — the number of test cases. The description of the test cases follows.

    The first line of each test case contains an integer nn (1≤n≤1001≤n≤100) — the number of columns of the grid.

    The following two lines each contain a string consisting of nn characters, each of which is either R, G, or B, representing a red, green, or blue cell, respectively — the description of the grid.

    Output

    For each test case, output "YES" if Vasya considers the grid's two rows to be identical, and "NO" otherwise.

    You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

    Example

    input

    Copy

     
    

    6

    2

    RG

    RB

    4

    GRBG

    GBGB

    5

    GGGGG

    BBBBB

    7

    BBBBBBB

    RRRRRRR

    8

    RGBRRGBR

    RGGRRBGR

    1

    G

    G

    output

    Copy

    YES
    NO
    YES
    NO
    YES
    YES
    

    Note

    In the first test case, Vasya sees the second cell of each row as the same because the second cell of the first row is green and the second cell of the second row is blue, so he can't distinguish these two cells. The rest of the rows are equal in colour. Therefore, Vasya will say that the two rows are coloured the same, even though they aren't.

    In the second test case, Vasya can see that the two rows are different.

    In the third test case, every cell is green or blue, so Vasya will think they are the same.

    解题说明:此题是一道模拟题,只需要判断两行中红色出现的位置是否相同,除了这些位置外不再出现红色即可。

    1. #include
    2. #include
    3. int main()
    4. {
    5. int t;
    6. scanf("%d", &t);
    7. while (t--)
    8. {
    9. int i, n, flag = 0;
    10. scanf("%d", &n);
    11. char s1[101], s2[101];
    12. scanf("%s%s", s1, s2);
    13. for (i = 0; i
    14. {
    15. if ((s1[i] == 'R' && s2[i] != 'R') || (s2[i] == 'R' && s1[i] != 'R'))
    16. {
    17. flag = 1;
    18. }
    19. }
    20. if (flag == 1)
    21. {
    22. printf("NO\n");
    23. }
    24. else
    25. {
    26. printf("YES\n");
    27. }
    28. }
    29. return 0;
    30. }

  • 相关阅读:
    通过简单的中介者模式模型了解迪米特法则(设计模式与开发实践 P14)
    CleanMyMacX 永久版下载激活码破解版
    HK32F030MF4P6 SWD管脚功能复用GPIO
    腾讯mini项目-【指标监控服务重构】2023-07-30
    【unity小技巧】unity事件系统创建通用的对象交互的功能
    设计模式——策略模式
    攻防世界WEB(二)baby_web、Training-WWW-Robots、PHP2、unserialize3
    【LeetCode周赛】LeetCode第368场周赛
    生成带干扰线的验证码
    python接口自动化测试(单元测试方法)
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/127136425