QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49668 | #1087. Brief Statements Union | AutumnKite | WA | 2ms | 3632kb | C++17 | 1.8kb | 2022-09-22 11:39:11 | 2022-09-22 11:39:14 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<int> l(m), r(m);
std::vector<long long> v(m);
for (int i = 0; i < m; ++i) {
std::cin >> l[i] >> r[i] >> v[i];
--l[i];
}
std::vector<int> ans(m, 1);
for (int k = 0; k < 60; ++k) {
std::vector<int> c(n + 1);
std::vector<long long> ci(n + 1);
for (int i = 0; i < m; ++i) {
if (v[i] >> k & 1) {
++c[l[i]], --c[r[i]];
ci[l[i]] += i, ci[r[i]] -= i;
}
}
for (int i = 0; i < n; ++i) {
c[i + 1] += c[i];
ci[i + 1] += ci[i];
}
std::vector<int> sum(n + 1), lst(n);
for (int i = 0; i < n; ++i) {
sum[i + 1] = sum[i] + !c[i];
if (c[i] != 1) {
ci[i] = -1;
}
if (i > 0 && (ci[i] == -1 || ci[i] == ci[lst[i - 1]])) {
lst[i] = lst[i - 1];
} else {
lst[i] = i;
}
}
std::vector<int> id;
for (int i = 0; i < m; ++i) {
if (!(v[i] >> k & 1) && sum[r[i]] == sum[l[i]]) {
id.push_back(i);
}
}
if (id.empty()) {
continue;
}
std::vector<int> s(m);
if (id.size() == 1) {
s[id[0]] = 1;
}
std::vector<int> d(n + 1);
for (int i : id) {
if (lst[r[i] - 1] >= l[i]) {
++d[lst[l[i]]], --d[r[i]];
}
}
for (int i = 0; i < n; ++i) {
d[i + 1] += d[i];
}
for (int i = 0; i < n; ++i) {
if (ci[i] != -1 && lst[i] == i && d[i] == (int)id.size()) {
s[ci[i]] = 1;
}
}
for (int i = 0; i < m; ++i) {
ans[i] &= s[i];
}
}
for (int i = 0; i < m; ++i) {
std::cout << ans[i];
}
std::cout << "\n";
}
/*
2 3
1 2 1
2 2 0
2 2 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3632kb
input:
4 3 1 2 1 2 4 3 2 2 1
output:
011
result:
ok "011"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
4 3 1 2 1 3 4 3 2 3 1
output:
111
result:
ok "111"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
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:
00000000
result:
wrong answer 1st words differ - expected: '10000000', found: '00000000'