QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576078 | #9345. Artful Paintings | lqh2024# | WA | 0ms | 3972kb | C++17 | 4.9kb | 2024-09-19 18:17:06 | 2024-09-19 18:17:07 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // 包含 tree、gp_hash_table、cc_hash_table
#include <ext/pb_ds/priority_queue.hpp> // 引入后使用 STL 的堆需要 std::
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
template<class key, class val = null_type, class cmp = less<>>
using rb_tree = tree<key, val, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class cmp = less<>>
using pairing_heap = __gnu_pbds::priority_queue<key, cmp>;
typedef long long ll;
#define int long long
template<class T> void print_debug(const T & v) { cerr << v; }
template<class T, class ... A> void print_debug(const T & v, const A & ... a) { cerr << v << ", ", print_debug(a...); }
#define debug(...) (cerr << "[" << #__VA_ARGS__ << "] = [", print_debug(__VA_ARGS__), cerr << "]\n")
mt19937_64 rd(time(0));
const int mod = 1e9 + 7;
template <class Info, class Tag>
struct SegTree : vector<Info> { // 左闭右开,注意初始化数组需要有 l, r
using tr = vector<Info>;
vector<Tag> tag;
void init(const tr & t) { // t.size() > 0
tr::assign(4 << __lg(t.size()), {}), tag.assign(tr::size(), {});
auto build = [&](auto && self, int l, int r, int p = 0) {
if (l + 1 == r) return tr::at(p) = t[l], void();
int m = l + r >> 1;
self(self, l, m, p << 1 | 1), self(self, m, r, p + 1 << 1), pull(p);
};
build(build, 0, t.size());
}
SegTree(int n) {
tr t(max<int>(1, n));
for (int i = 0; i < t.size(); t[i++] = {i, i + 1});
init(t);
}
SegTree(const tr & t) { init(t); }
void pull(int p) { tr::at(p).pull(tr::at(p << 1 | 1) + tr::at(p + 1 << 1)); }
void update(int p, const Tag & t) { tr::at(p).update(t), tag[p] += t; }
void push(int p) { update(p << 1 | 1, tag[p]), update(p + 1 << 1, tag[p]), tag[p] = {}; }
void update(int l, int r, const Tag & t, int p = 0) {
if (r <= tr::at(p)[0] || tr::at(p)[1] <= l) return;
if (l <= tr::at(p)[0] && tr::at(p)[1] <= r) return update(p, t);
push(p), update(l, r, t, p << 1 | 1), update(l, r, t, p + 1 << 1), pull(p);
}
Info query(int l, int r, int p = 0) {
if (r <= tr::at(p)[0] || tr::at(p)[1] <= l) return {l, r};
if (l <= tr::at(p)[0] && tr::at(p)[1] <= r) return tr::at(p);
return push(p), query(l, r, p << 1 | 1) + query(l, r, p + 1 << 1);
}
template <class F>
int FindFirst(int l, int r, F && chk, int p = 0) {
if (r <= tr::at(p)[0] || tr::at(p)[1] <= l || !chk(tr::at(p))) return -1;
if (tr::at(p)[0] + 1 == tr::at(p)[1]) return p;
push(p); int res = FindFirst(l, r, chk, p << 1 | 1);
return res == -1 ? FindFirst(l, r, chk, p + 1 << 1) : res;
}
template <class F>
int FindLast(int l, int r, F && chk, int p = 0) {
if (r <= tr::at(p)[0] || tr::at(p)[1] <= l || !chk(tr::at(p))) return -1;
if (tr::at(p)[0] + 1 == tr::at(p)[1]) return p;
push(p); int res = FindLast(l, r, chk, p + 1 << 1);
return res == -1 ? FindLast(l, r, chk, p << 1 | 1) : res;
}
};
void QAQ() {
int n, m1, m2;
cin >> n >> m1 >> m2;
vector<array<int, 3>> a(m1 + m2 + 1);
// vector<int> cnt(n + 1);
for (int i = 1; i <= m1 + m2; i++) {
int l, r, k;
cin >> l >> r >> k;
a[i] = {l, r, k};
}
int mx = 0;
for (int j = 1; j <= m1 + m2; j++) {
mx = max(mx, a[j][2]);
}
if (mx == 0) {
cout << 0 << "\n";
return;
}
vector<int> vis(n + 1);
for (int i = 1; i <= n; i++) {
vector<int> cnt(n + 1);
for (int j = 1; j <= m1 + m2; j++) {
auto &[l ,r, k] = a[j];
if (k == 0) continue;
if (j <= m1) {
cnt[l]++;
cnt[r + 1]--;
} else {
cnt[1]++;
cnt[l]--;
cnt[r + 1]++;
}
}
int mx = 0, p = 0;
for (int j = 1; j <= n; j++) {
cnt[j] += cnt[j - 1];
if (cnt[j] > mx && !vis[j]) {
mx = cnt[j];
p = j;
}
}
vis[p] = 1;
for (int j = 1; j <= m1 + m2; j++) {
auto &[l, r, k] = a[j];
if (!k) continue;
if (j <= m1) {
k -= l <= p && p <= r;
} else {
k -= p < l || p > r;
}
}
mx = 0;
for (int j = 1; j <= m1 + m2; j++) {
mx = max(mx, a[j][2]);
}
if (mx == 0) {
cout << i << "\n";
return;
}
}
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
cout << fixed << setprecision(12);
int t = 1;
cin >> t;
while (t--) {
QAQ();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
1 3 1 1 1 2 1 2 2 1
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3972kb
input:
1 1000 500 500 479 860 170 73 939 25 363 772 30 185 584 89 326 482 10 784 949 23 384 740 114 233 693 45 167 724 211 217 436 95 46 701 153 138 585 67 321 388 11 114 890 194 407 854 74 438 845 117 9 718 259 393 576 35 182 707 257 451 766 136 150 382 31 468 785 40 202 490 46 326 815 59 272 441 77 123 8...
output:
509
result:
wrong answer 1st lines differ - expected: '492', found: '509'