QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#794133#1087. Brief Statements UnionbadmintonWA 64ms59080kbC++142.7kb2024-11-30 11:39:232024-11-30 11:39:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-30 11:39:26]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:59080kb
  • [2024-11-30 11:39:23]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

template<class X, class Y>
    bool minz(X &x, const Y &y) {
        if (x > y) {
            x = y;
            return true;
        } return false;
    }
template<class X, class Y>
    bool maxz(X &x, const Y &y) {
        if (x < y) {
            x = y;
            return true;
        } return false;
    }

const int N = 1e6 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;

ll x[N], l[N], r[N], id[N], add[N], n, k, ok[N], vis[N];
vector <ll> ask[N];

void solve(int o){
    memset (add, 0, sizeof add);
    memset (id, 0, sizeof id);
    memset (vis, 0, sizeof vis);

    forr (i, 1, k){
        if (bit(x[i], o)){
            add[l[i]]++;
            add[r[i] + 1]--;
            id[l[i]] = i;
        } else {
            ask[r[i]].pb(i);
        }
    }

    int lst = 0, cur = 0;
    vector <int> bad;

    forr (i, 1, n){
        add[i] += add[i - 1];
        if (!add[i]) lst = i;

        if (id[i] && r[id[i]] >= r[cur]){
            cur = id[i];
        }
        id[i] = cur;

        for (int u : ask[i]){
            if (lst < l[u]){
                bad.pb(u);
            }
        }

        ask[i].clear();
    }


    if (bad.empty()){
        forr (i, 1, k){
            ok[i]++;
        }
    } else {
        if (bad.size() == 1) ok[bad[0]]++;

        int ml = mod, mr = -1;
        for (int u : bad){
            minz(ml, l[u]);
            maxz(mr, r[u]);
        }

        if (ml > mr) return;

        forr (i, ml, mr){
            if (add[i] == 1 && !vis[id[i]]){
                ok[id[i]]++;
                vis[id[i]]++;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif

    cin >> n >> k;

    forr (i, 1, k){
        cin >> l[i] >> r[i] >> x[i];
    }

    forf (i, 0, 60){
        solve(i);
    }

    forr (i, 1, k){
        cout << (ok[i] == 60);
    }


    return 0;
}
/*



*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 64ms
memory: 56660kb

input:

4 3
1 2 1
2 4 3
2 2 1

output:

011

result:

ok "011"

Test #2:

score: 0
Accepted
time: 64ms
memory: 56788kb

input:

4 3
1 2 1
3 4 3
2 3 1

output:

111

result:

ok "111"

Test #3:

score: 0
Accepted
time: 59ms
memory: 57848kb

input:

8 8
1 3 23
2 8 8
2 4 10
3 3 26
1 3 26
1 4 10
4 7 8
4 5 40

output:

10000000

result:

ok "10000000"

Test #4:

score: 0
Accepted
time: 58ms
memory: 56420kb

input:

8 8
3 5 9
3 3 63
6 7 57
1 4 44
5 5 63
1 7 40
1 7 40
7 8 0

output:

10000000

result:

ok "10000000"

Test #5:

score: 0
Accepted
time: 57ms
memory: 57940kb

input:

8 8
3 8 21
6 8 4
1 7 20
1 7 20
6 6 61
4 6 29
2 2 31
5 6 61

output:

11000000

result:

ok "11000000"

Test #6:

score: 0
Accepted
time: 55ms
memory: 59080kb

input:

8 8
7 8 21
2 6 26
3 3 63
4 5 58
1 1 55
2 8 10
3 3 63
2 8 10

output:

10000000

result:

ok "10000000"

Test #7:

score: 0
Accepted
time: 61ms
memory: 58180kb

input:

8 8
6 7 21
7 8 59
5 8 43
7 7 63
3 5 45
1 1 31
3 6 45
2 3 61

output:

10000000

result:

ok "10000000"

Test #8:

score: 0
Accepted
time: 58ms
memory: 56788kb

input:

8 8
2 8 2
2 8 4
6 6 14
4 8 4
6 8 4
3 3 31
5 7 12
4 4 13

output:

10000000

result:

ok "10000000"

Test #9:

score: -100
Wrong Answer
time: 62ms
memory: 56784kb

input:

8 8
1 8 12
3 6 36
1 5 36
3 8 4
7 8 6
3 4 47
1 3 45
1 4 45

output:

00000100

result:

wrong answer 1st words differ - expected: '10000000', found: '00000100'