CF数据有没有树脂
查看原帖
CF数据有没有树脂
578004
02Ljh楼主2023/10/16 13:52

在某网站上看到的某老哥的code 感觉会TLE

但是不仅赛时冲过去了 CF 上也过了 求复杂度证明(

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <stdlib.h>
#include <queue>

#define ll long long
#define ld long double

#define MAXN 300005

using namespace std;

inline ll read() {
    char c = getchar();
    ll x = 0, s = 1;
    while (c < '0' || c > '9') {
        if (c == '-')
            s = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * s;
}

int n, q;

int a[MAXN];

int main() {

    n = read();
    q = read();

    for (int i = 1; i <= n; i++) a[i] = read();

    for (int i = 1; i <= q; i++) {
        int x = read(), y = read();
        int num = a[x];
        if (!a[x] || !a[y]) {
            cout << "Fou\n";
            continue;
        }

        for (int j = x + 1; j <= y; j++) {
            if (a[j] & num)
                num |= a[j];
            if (num & a[y])
                break;
        }

        if (num & a[y])
            cout << "Shi\n";
        else
            cout << "Fou\n";
    }

    return 0;
}
2023/10/16 13:52
加载中...