Submission #38709544


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
int inc(const int &a, const int &b)
{
    return a + b >= MOD ? a + b - MOD : a + b;
}
void Mul(int &a, const int &b)
{
    a = 1LL * a * b % MOD;
}
void Sqr(int &a)
{
    a = 1LL * a * a % MOD;
}
int qwqmi(int x, int k = MOD - 2)
{
    int res = 1;
    while(k)
    {
        if(k & 1) Mul(res, x);
        Sqr(x), k >>= 1;
    }
    return res;
}
const int N = 1e3 + 5;
int n, ans, f[N];
char c[2][2];
int main()
{
    scanf("%d", &n);
    scanf(" %c", &c[0][0]);
    scanf(" %c", &c[0][1]);
    scanf(" %c", &c[1][0]);
    scanf(" %c", &c[1][1]);
    if(n == 2)
    {
        puts("1");
        return 0;
    }
    f[0] = 1;
    f[1] = 2;
    for(int i = 2; i < N; ++i)
        f[i] = inc(f[i - 1], f[i - 2]);
    if(c[0][1] == 'A')
    {
        if(c[0][0] == 'A')
            ans = 1;
        else
        {
            if(c[1][0] == 'B')
                ans = qwqmi(2, n - 3);
            else
                ans = f[n - 3];
        }
    }
    if(c[0][1] == 'B')
    {
        if(c[1][1] == 'B')
            ans = 1;
        else
        {
            if(c[1][0] == 'A')
                ans = qwqmi(2, n - 3);
            else
                ans = f[n - 3];
        }
    }
    printf("%d\n", ans);
    return 0;
}

Submission Info

Submission Time
Task D - AB
User Schucking_Sattin
Language C++ (GCC 9.2.1)
Score 600
Code Size 1383 Byte
Status AC
Exec Time 7 ms
Memory 3796 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   32 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
./Main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   33 |     scanf(" %c", &c[0][0]);
      |     ~~~~~^~~~~~~~~~~~~~~~~
./Main.cpp:34:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   34 |     scanf(" %c", &c[0][1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~
./Main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   35 |     scanf(" %c", &c[1][0]);
      |     ~~~~~^~~~~~~~~~~~~~~~~
./Main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   36 |     scanf(" %c", &c[1][1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 82
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, hand_27.txt, hand_28.txt, hand_29.txt, hand_30.txt, hand_31.txt, hand_32.txt, hand_33.txt, hand_34.txt, hand_35.txt, hand_36.txt, hand_37.txt, hand_38.txt, hand_39.txt, hand_40.txt, hand_41.txt, hand_42.txt, hand_43.txt, hand_44.txt, hand_45.txt, hand_46.txt, hand_47.txt, hand_48.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 7 ms 3624 KiB
hand_02.txt AC 2 ms 3508 KiB
hand_03.txt AC 2 ms 3656 KiB
hand_04.txt AC 2 ms 3492 KiB
hand_05.txt AC 2 ms 3508 KiB
hand_06.txt AC 3 ms 3732 KiB
hand_07.txt AC 3 ms 3728 KiB
hand_08.txt AC 2 ms 3596 KiB
hand_09.txt AC 2 ms 3728 KiB
hand_10.txt AC 2 ms 3628 KiB
hand_11.txt AC 2 ms 3504 KiB
hand_12.txt AC 3 ms 3500 KiB
hand_13.txt AC 2 ms 3496 KiB
hand_14.txt AC 2 ms 3624 KiB
hand_15.txt AC 1 ms 3576 KiB
hand_16.txt AC 1 ms 3496 KiB
hand_17.txt AC 2 ms 3692 KiB
hand_18.txt AC 2 ms 3700 KiB
hand_19.txt AC 2 ms 3576 KiB
hand_20.txt AC 3 ms 3736 KiB
hand_21.txt AC 2 ms 3688 KiB
hand_22.txt AC 2 ms 3692 KiB
hand_23.txt AC 2 ms 3792 KiB
hand_24.txt AC 2 ms 3796 KiB
hand_25.txt AC 2 ms 3620 KiB
hand_26.txt AC 2 ms 3568 KiB
hand_27.txt AC 2 ms 3572 KiB
hand_28.txt AC 2 ms 3700 KiB
hand_29.txt AC 2 ms 3616 KiB
hand_30.txt AC 2 ms 3572 KiB
hand_31.txt AC 3 ms 3688 KiB
hand_32.txt AC 2 ms 3620 KiB
hand_33.txt AC 2 ms 3692 KiB
hand_34.txt AC 2 ms 3692 KiB
hand_35.txt AC 2 ms 3640 KiB
hand_36.txt AC 2 ms 3692 KiB
hand_37.txt AC 2 ms 3796 KiB
hand_38.txt AC 2 ms 3784 KiB
hand_39.txt AC 2 ms 3568 KiB
hand_40.txt AC 3 ms 3620 KiB
hand_41.txt AC 2 ms 3684 KiB
hand_42.txt AC 2 ms 3688 KiB
hand_43.txt AC 2 ms 3612 KiB
hand_44.txt AC 2 ms 3572 KiB
hand_45.txt AC 2 ms 3616 KiB
hand_46.txt AC 2 ms 3728 KiB
hand_47.txt AC 2 ms 3728 KiB
hand_48.txt AC 2 ms 3692 KiB
random_01.txt AC 2 ms 3684 KiB
random_02.txt AC 2 ms 3684 KiB
random_03.txt AC 2 ms 3684 KiB
random_04.txt AC 2 ms 3696 KiB
random_05.txt AC 2 ms 3788 KiB
random_06.txt AC 2 ms 3640 KiB
random_07.txt AC 2 ms 3684 KiB
random_08.txt AC 2 ms 3700 KiB
random_09.txt AC 2 ms 3688 KiB
random_10.txt AC 2 ms 3620 KiB
random_11.txt AC 3 ms 3688 KiB
random_12.txt AC 2 ms 3728 KiB
random_13.txt AC 2 ms 3684 KiB
random_14.txt AC 2 ms 3572 KiB
random_15.txt AC 2 ms 3616 KiB
random_16.txt AC 2 ms 3572 KiB
random_17.txt AC 2 ms 3732 KiB
random_18.txt AC 2 ms 3728 KiB
random_19.txt AC 2 ms 3616 KiB
random_20.txt AC 2 ms 3792 KiB
random_21.txt AC 2 ms 3792 KiB
random_22.txt AC 2 ms 3568 KiB
random_23.txt AC 2 ms 3712 KiB
random_24.txt AC 2 ms 3724 KiB
random_25.txt AC 2 ms 3684 KiB
random_26.txt AC 2 ms 3620 KiB
random_27.txt AC 2 ms 3612 KiB
random_28.txt AC 2 ms 3680 KiB
random_29.txt AC 2 ms 3568 KiB
random_30.txt AC 2 ms 3688 KiB
random_31.txt AC 2 ms 3736 KiB
random_32.txt AC 2 ms 3732 KiB
sample_01.txt AC 2 ms 3572 KiB
sample_02.txt AC 2 ms 3688 KiB