QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587230 | #9237. Message | Y_zhao | Compile Error | / | / | C++20 | 2.4kb | 2024-09-24 18:36:35 | 2024-09-24 18:36:40 |
Judging History
answer
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
using u64 = uint64_t;
using bs = bitset<500000>;
bs mask;
mt19937 rd(random_device{}());
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int n = 1000;
#ifndef DEBUG
cin >> n;
#endif
for (int i = 0; i <= n; i++) {
mask[i] = 1;
}
vector<vector<pair<int, int>>> p(n + 1);
for (int i = 1; i <= n; i++) {
int x, y, c;
#ifdef DEBUG
x = rd() % n + 1, y = rd() % n + 1, c = rd() % n + 1;
#else
cin >> x >> y >> c;
#endif
p[x].push_back({y, c});
}
struct Val {
bs s;
int x, n;
u64 sum;
void add(int c) {
bs ns = s | (s << c) | (s >> (n - c)), tmp = ns ^ s;
for (int i = tmp._Find_first(); i < n; i = tmp._Find_next(i)) {
sum += i;
}
s = ns;
}
bool full() const { return sum == n * (n - 1ull) / 2; }
};
vector<Val> f = {Val{1, 0, n, 0}};
auto calc = [&](int l, int r) { return (l + r) * (r - l + 1ll) / 2; };
auto query = [&]() -> u64 {
u64 res = 0;
for (int i = 0; i + 1 < (int)f.size(); i++) {
res += f[i].sum * calc(f[i].x, f[i + 1].x - 1);
}
res += f.back().sum * calc(f.back().x, n);
return res;
};
u64 ans = 0;
int tag = 0, mxc = 0;
for (int i = 1; i <= n; i++) {
sort(p[i].begin(), p[i].end());
for (auto [y, c] : p[i]) {
if (!f.back().full() || y < f.back().x) {
for (int j = 0; j < (int)f.size(); j++) {
if (j + 1 == (int)f.size() || f[j + 1].x > y) {
f.insert(f.begin() + j + 1, f[j]);
f[j + 1].x = y;
for (int k = j + 1; k < (int)f.size(); k++) {
f[k].add(c);
++tag;
}
while ((int)f.size() >= 2 && f.end()[-2].full()) {
f.pop_back();
}
break;
}
}
}
}
mxc = max(mxc, (int)f.size());
ans += query() * i;
}
cerr << tag << ' ' << mxc << '\n';
cout << ans << '\n';
return 0;
}
Details
/usr/bin/ld: /tmp/ccSGCk4J.o: in function `main': stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccSq8IfG.o:answer.code:(.text.startup+0xf0): first defined here /usr/bin/ld: /tmp/ccSGCk4J.o: in function `(anonymous namespace)::run_decoder()': stub.cpp:(.text+0x701): undefined reference to `receive_message(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >)' /usr/bin/ld: /tmp/ccSGCk4J.o: in function `(anonymous namespace)::run_encoder()': stub.cpp:(.text+0xc83): undefined reference to `send_message(std::vector<bool, std::allocator<bool> >, std::vector<bool, std::allocator<bool> >)' collect2: error: ld returned 1 exit status