QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#794178#1087. Brief Statements UnionbadmintonWA 163ms82596kbC++143.6kb2024-11-30 12:38:462024-11-30 12:38:47

Judging History

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

  • [2024-11-30 12:38:47]
  • 评测
  • 测评结果:WA
  • 用时:163ms
  • 内存:82596kb
  • [2024-11-30 12:38:46]
  • 提交

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], pre[N], suf[N], add2[N];
vector <ll> ask[N];

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

    forr (i, 1, k){
        if (bit(x[i], o)){
            add[l[i]]++;
            add[r[i] + 1]--;
            add2[l[i] - 1]--;
            add2[r[i]]++;
            if (!id[l[i]] || r[id[l[i]]] < r[i])
            id[l[i]] = i;
        } else {
            ask[r[i]].pb(i);
        }
       // cout << bit(x[i], o) << " ";
       // cout << "\n";
    }

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

    forr (i, 1, n){
        add[i] += add[i - 1];
        if (!add[i]) lst = i;
        if (add[i] == 1) lmao = 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);
                if (lmao < l[u]){
                    cook = 1;
                }
            }
        }

        pre[i] = lmao;

        //cout << add[i] << " " << id[i] << endl;
        ask[i].clear();
    }

    lmao = n + 1;
    ford (i, n, 1){
        add2[i] += add2[i + 1];
        if (add2[i] == 1) lmao = i;
        suf[i] = lmao;
    }


    //cout << "bad\n";
   // for (int u : bad) cout << l[u] << " " << r[u] << endl;


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

        int ml = bad[0], mr = bad[0];
        for (int u : bad){
            if (l[u] > l[ml]) ml = u;
            if (r[u] < r[mr]) mr = u;
        }

        //cout << ml << " " << l[ml] << " " << mr << " " << r[mr] << endl;
        //cout << id[pre[l[ml]]] << " " << id[suf[r[mr]]] << "\n";
        if (id[pre[l[ml]]] == id[suf[r[mr]]]){
            ok[id[pre[ml]]]++;
        }
    }
}

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] << " ";
        //}
        //cout << endl;
    }

    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: 154ms
memory: 80416kb

input:

4 3
1 2 1
2 4 3
2 2 1

output:

011

result:

ok "011"

Test #2:

score: 0
Accepted
time: 163ms
memory: 81372kb

input:

4 3
1 2 1
3 4 3
2 3 1

output:

111

result:

ok "111"

Test #3:

score: 0
Accepted
time: 163ms
memory: 82596kb

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: 162ms
memory: 81276kb

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: -100
Wrong Answer
time: 149ms
memory: 79740kb

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:

01000000

result:

wrong answer 1st words differ - expected: '11000000', found: '01000000'