2.2NEWCODE1

#include<iostream>
#include<string>
using namespace std;
int n, s;
string a;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int da[4] = { 0 }, xiao[4] = { 0 };
        cin >> s >> a;
        for (int j = 0; j < s; j++) {
            if (a[j] == 'd')xiao[0]++;
            if (a[j] == 'f')xiao[1] += xiao[0];
            if (a[j] == 's')xiao[2] += xiao[1];
            if (a[j] == 'D')da[0]++;
            if (a[j] == 'F')da[1] += da[0];
            if (a[j] == 'S')da[2] += da[1];
        }
        cout << (xiao[2] ? 1 : 0) << " " << (da[2] ? 1 : 0) << endl;
    }
    return 0;
}
        map<long long, long long>m;
        int flagl = 0, flagr = 0;
        cin >> num;
        for (int i = 1; i <= num; i++) {
            cin >> r >> c;
            if (!m[c]) {
                m[c] = r;
                if (c < 0) {
                    if ((m[c - 1] && m[c - 1] != m[c]) || (m[c + 1] && m[c + 1] != m[c])) {
                        flagl = 2;
                    }
                    else {
                        flagl = max(1, flagl);
                    }
                }
                if (c > 0) {
                    if ((c-1>=1e9&&m[c - 1] && m[c - 1] != m[c]) || (c+1<=1e9&&m[c + 1] && m[c + 1] != m[c])) {
                        flagr = 2;
                    }
                    else {
                        flagr = max(1, flagr);
                    }
                }
            }
            else {
                if (c < 0)flagl = 2;
                    if (c > 0)flagr = 2;
            }
        }
        if (!m[0]){
            cout<<min(1+min(2-flagr,((m[1]&&m[1]==1)?0:1))+min(2-flagl,((m[-1]&&m[-1]==1)?0:1)),4-flagl-flagr)<<endl;
        }
        if (m[0]) {
            //cout<<222<<endl;
            cout << min(2-flagl,1)+min(2-flagr,1) << endl;
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值