QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#794131 | #1087. Brief Statements Union | badminton | WA | 43ms | 51464kb | C++14 | 2.6kb | 2024-11-30 11:37:10 | 2024-11-30 11:37:18 |
Judging History
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];
vector <ll> ask[N];
void solve(int o){
memset (add, 0, sizeof add);
memset (id, 0, sizeof id);
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 && (i == ml || id[i] != id[i - 1])){
ok[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: 37ms
memory: 50348kb
input:
4 3 1 2 1 2 4 3 2 2 1
output:
011
result:
ok "011"
Test #2:
score: 0
Accepted
time: 39ms
memory: 50288kb
input:
4 3 1 2 1 3 4 3 2 3 1
output:
111
result:
ok "111"
Test #3:
score: 0
Accepted
time: 38ms
memory: 48768kb
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: 42ms
memory: 51464kb
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: 43ms
memory: 50024kb
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'