15492022-11-23 12:50:45zsebiBimmbamm (30)cpp11Accepted 30/303ms3536 KiB
#include <iostream>
#include <string>

using namespace std;
string s;
string a = "BIMM";
string b = "BAMM";
string c = "BUMM";
int n, ok, i;
int main()
{
    cin >> n;
    getline(cin, s);
    ok = 0;
    for (i = 1; i <= n; ++i)
    {
        cin >> s;

        if (i % 3 == 0 && i % 5 == 0)
        {
            if (s[1] != c[1])
            {
                cout << i;
                ok = 1;
                break;
            }
        }
        else if (i % 3 == 0)
        {
            if (s[1] != a[1])
            {

                cout << i;
                ok = 1;
                break;

            }
        }
        else if (i % 5 == 0)
        {

            if (s[1] != b[1])
            {

                cout << i;
                ok = 1;
                break;
            }
        }
        else if (s[0] != 'S')
        {
            cout << i;
            return 0;
        }
    }
    if (ok == 0)cout << "0";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1876 KiB
2Accepted0/02ms2072 KiB
3Accepted3/32ms2272 KiB
4Accepted3/32ms2480 KiB
5Accepted3/32ms2556 KiB
6Accepted3/32ms2828 KiB
7Accepted3/32ms2908 KiB
8Accepted3/32ms3012 KiB
9Accepted3/32ms3260 KiB
10Accepted3/32ms3344 KiB
11Accepted3/32ms3332 KiB
12Accepted3/32ms3536 KiB