QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212227 | #1147. Wall | zzy0922 | Compile Error | / | / | C++14 | 7.0kb | 2023-10-13 12:29:53 | 2023-10-13 12:29:53 |
Judging History
answer
#include <bits/stdc++.h>
// using namespace std;
using std::endl;
int n, k;
void chkmax(int &x, const int &v) {
x = std::max(x, v);
}
void chkmin(int &x, const int &v) {
x = std::min(x, v);
}
struct node{
int l, r, mx1, mx2, mi1, mi2, asn;
bool tag;
}tree[8000005];
#define ls(p) (p << 1)
#define rs(p) (ls(p) | 1)
#define l(p) tree[p].l
#define r(p) tree[p].r
#define mx1(p) tree[p].mx1
#define mx2(p) tree[p].mx2
#define mi1(p) tree[p].mi1
#define mi2(p) tree[p].mi2
#define tag(p) tree[p].tag
#define asn(p) tree[p].asn
inline void pushup(const int &p) {
mx1(p) = std::max(mx1(ls(p)), mx1(rs(p)));
mx2(p) = 0;
if (mx1(ls(p)) != mx1(p)) chkmax(mx2(p), mx1(ls(p)));
if (mx1(rs(p)) != mx1(p)) chkmax(mx2(p), mx1(rs(p)));
if (mx2(ls(p)) != mx1(p)) chkmax(mx2(p), mx2(ls(p)));
if (mx2(rs(p)) != mx1(p)) chkmax(mx2(p), mx2(rs(p)));
mi1(p) = std::min(mi1(ls(p)), mi2(rs(p)));
mi2(p) = 0x7fffffff;
if (mi1(ls(p)) != mi1(p)) chkmin(mi2(p), mi1(ls(p)));
if (mi1(rs(p)) != mi1(p)) chkmin(mi2(p), mi1(rs(p)));
if (mi2(ls(p)) != mi1(p)) chkmin(mi2(p), mi2(ls(p)));
if (mi2(rs(p)) != mi1(p)) chkmin(mi2(p), mi2(rs(p)));
if (mx1(p) == mi1(p)) tag(p) = 1;
else tag(p) = 0;
}
inline void pushdown(int p) {
if (tag(p) && ~asn(p)) {
mx1(ls(p)) = mx1(rs(p)) = mi1(ls(p)) = mi1(rs(p)) = asn(ls(p)) = asn(rs(p)) = asn(p);
asn(p) = -1;
}
chkmin(mx1(ls(p)), mx1(p));
chkmin(mx1(rs(p)), mx1(p));
chkmax(mi1(ls(p)), mi1(p));
chkmax(mi1(rs(p)), mi1(p));
}
void build(int p, int l, int r) {
l(p) = l, r(p) = r;
if (l == r) {
tag(p) = 1;
return;
}
int mid = (l + r) >> 1;
build(ls(p), l, mid);
build(rs(p), mid + 1, r);
pushup(p);
}
void chkmaxlr(int p, int l, int r, int v) {
if (l > r(p) || r < l(p)) return;
if (l <= l(p) && r(p) <= r) {
chkmax(mi1(p), v);
chkmax(mx1(p), v);
if (tag(p)) {
mx1(p) = mi1(p) = asn(p) = std::max(mx1(p), v);
return;
}
if (v >= mi2(p)) {
pushdown(p);
chkmaxlr(ls(p), l, r, v);
chkmaxlr(rs(p), l, r, v);
pushup(p);
return;
}
}
pushdown(p);
chkmaxlr(ls(p), l, r, v);
chkmaxlr(rs(p), l, r, v);
pushup(p);
}
void chkminlr(int p, int l, int r, int v) {
if (l > r(p) || r < l(p)) return;
if (l <= l(p) && r(p) <= r) {
chkmin(mx1(p), v);
chkmin(mi1(p), v);
if (tag(p)) {
mx1(p) = mi1(p) = asn(p) = std::min(mx1(p), v);
return;
}
if (v <= mx2(p)) {
pushdown(p);
chkminlr(ls(p), l, r, v);
chkminlr(rs(p), l, r, v);
pushup(p);
return;
}
}
pushdown(p);
chkminlr(ls(p), l, r, v);
chkminlr(rs(p), l, r, v);
pushup(p);
}
void dfs(int p) {
if (l(p) == r(p)) {
std::cout << mx1(p) << '\n';
return;
}
pushdown(p);
dfs(ls(p));
dfs(rs(p));
}
int op, l, r, h;
int main() {
//freopen("wall.in", "r", stdin);
//freopen("wall.out", "w", stdout);
std::cin.tie(0)->sync_with_stdio(0);
std::cin >> n >> k;
build(1, 1, n);
while (k--) {
std::cin >> op >> l >> r >> h;
if (op == 1) chkmaxlr(1, l + 1, r + 1, h);
else chkminlr(1, l + 1, r + 1, h);
}
dfs(1);
return 0;
}#include <bits/stdc++.h>
// using namespace std;
using std::endl;
int n, k;
void chkmax(int &x, const int &v) {
x = std::max(x, v);
}
void chkmin(int &x, const int &v) {
x = std::min(x, v);
}
struct node{
int l, r, mx1, mx2, mi1, mi2, asn;
bool tag;
}tree[8000005];
#define ls(p) (p << 1)
#define rs(p) (ls(p) | 1)
#define l(p) tree[p].l
#define r(p) tree[p].r
#define mx1(p) tree[p].mx1
#define mx2(p) tree[p].mx2
#define mi1(p) tree[p].mi1
#define mi2(p) tree[p].mi2
#define tag(p) tree[p].tag
#define asn(p) tree[p].asn
inline void pushup(const int &p) {
mx1(p) = std::max(mx1(ls(p)), mx1(rs(p)));
mx2(p) = 0;
if (mx1(ls(p)) != mx1(p)) chkmax(mx2(p), mx1(ls(p)));
if (mx1(rs(p)) != mx1(p)) chkmax(mx2(p), mx1(rs(p)));
if (mx2(ls(p)) != mx1(p)) chkmax(mx2(p), mx2(ls(p)));
if (mx2(rs(p)) != mx1(p)) chkmax(mx2(p), mx2(rs(p)));
mi1(p) = std::min(mi1(ls(p)), mi2(rs(p)));
mi2(p) = 0x7fffffff;
if (mi1(ls(p)) != mi1(p)) chkmin(mi2(p), mi1(ls(p)));
if (mi1(rs(p)) != mi1(p)) chkmin(mi2(p), mi1(rs(p)));
if (mi2(ls(p)) != mi1(p)) chkmin(mi2(p), mi2(ls(p)));
if (mi2(rs(p)) != mi1(p)) chkmin(mi2(p), mi2(rs(p)));
if (mx1(p) == mi1(p)) tag(p) = 1;
else tag(p) = 0;
}
inline void pushdown(int p) {
if (tag(p) && ~asn(p)) {
mx1(ls(p)) = mx1(rs(p)) = mi1(ls(p)) = mi1(rs(p)) = asn(ls(p)) = asn(rs(p)) = asn(p);
asn(p) = -1;
}
chkmin(mx1(ls(p)), mx1(p));
chkmin(mx1(rs(p)), mx1(p));
chkmax(mi1(ls(p)), mi1(p));
chkmax(mi1(rs(p)), mi1(p));
}
void build(int p, int l, int r) {
l(p) = l, r(p) = r;
if (l == r) {
tag(p) = 1;
return;
}
int mid = (l + r) >> 1;
build(ls(p), l, mid);
build(rs(p), mid + 1, r);
pushup(p);
}
void chkmaxlr(int p, int l, int r, int v) {
if (l > r(p) || r < l(p)) return;
if (l <= l(p) && r(p) <= r) {
chkmax(mi1(p), v);
chkmax(mx1(p), v);
if (tag(p)) {
mx1(p) = mi1(p) = asn(p) = std::max(mx1(p), v);
return;
}
if (v >= mi2(p)) {
pushdown(p);
chkmaxlr(ls(p), l, r, v);
chkmaxlr(rs(p), l, r, v);
pushup(p);
return;
}
}
pushdown(p);
chkmaxlr(ls(p), l, r, v);
chkmaxlr(rs(p), l, r, v);
pushup(p);
}
void chkminlr(int p, int l, int r, int v) {
if (l > r(p) || r < l(p)) return;
if (l <= l(p) && r(p) <= r) {
chkmin(mx1(p), v);
chkmin(mi1(p), v);
if (tag(p)) {
mx1(p) = mi1(p) = asn(p) = std::min(mx1(p), v);
return;
}
if (v <= mx2(p)) {
pushdown(p);
chkminlr(ls(p), l, r, v);
chkminlr(rs(p), l, r, v);
pushup(p);
return;
}
}
pushdown(p);
chkminlr(ls(p), l, r, v);
chkminlr(rs(p), l, r, v);
pushup(p);
}
void dfs(int p) {
if (l(p) == r(p)) {
std::cout << mx1(p) << '\n';
return;
}
pushdown(p);
dfs(ls(p));
dfs(rs(p));
}
int op, l, r, h;
int main() {
freopen("wall.in", "r", stdin);
freopen("wall.out", "w", stdout);
std::cin.tie(0)->sync_with_stdio(0);
std::cin >> n >> k;
build(1, 1, n);
while (k--) {
std::cin >> op >> l >> r >> h;
if (op == 1) chkmaxlr(1, l + 1, r + 1, h);
else chkminlr(1, l + 1, r + 1, h);
}
dfs(1);
return 0;
}
详细
answer.code:143:2: error: stray ‘#’ in program 143 | }#include <bits/stdc++.h> | ^ answer.code:143:3: error: ‘include’ does not name a type 143 | }#include <bits/stdc++.h> | ^~~~~~~ answer.code:147:5: error: redefinition of ‘int n’ 147 | int n, k; | ^ answer.code:5:5: note: ‘int n’ previously declared here 5 | int n, k; | ^ answer.code:147:8: error: redefinition of ‘int k’ 147 | int n, k; | ^ answer.code:5:8: note: ‘int k’ previously declared here 5 | int n, k; | ^ answer.code:149:6: error: redefinition of ‘void chkmax(int&, const int&)’ 149 | void chkmax(int &x, const int &v) { | ^~~~~~ answer.code:7:6: note: ‘void chkmax(int&, const int&)’ previously defined here 7 | void chkmax(int &x, const int &v) { | ^~~~~~ answer.code:153:6: error: redefinition of ‘void chkmin(int&, const int&)’ 153 | void chkmin(int &x, const int &v) { | ^~~~~~ answer.code:11:6: note: ‘void chkmin(int&, const int&)’ previously defined here 11 | void chkmin(int &x, const int &v) { | ^~~~~~ answer.code:157:8: error: redefinition of ‘struct node’ 157 | struct node{ | ^~~~ answer.code:15:8: note: previous definition of ‘struct node’ 15 | struct node{ | ^~~~ answer.code:160:2: error: conflicting declaration ‘int tree [8000005]’ 160 | }tree[8000005]; | ^~~~ answer.code:18:2: note: previous declaration as ‘node tree [8000005]’ 18 | }tree[8000005]; | ^~~~ answer.code:173:13: error: redefinition of ‘void pushup(const int&)’ 173 | inline void pushup(const int &p) { | ^~~~~~ answer.code:31:13: note: ‘void pushup(const int&)’ previously defined here 31 | inline void pushup(const int &p) { | ^~~~~~ answer.code:190:13: error: redefinition of ‘void pushdown(int)’ 190 | inline void pushdown(int p) { | ^~~~~~~~ answer.code:48:13: note: ‘void pushdown(int)’ previously defined here 48 | inline void pushdown(int p) { | ^~~~~~~~ answer.code:201:6: error: redefinition of ‘void build(int, int, int)’ 201 | void build(int p, int l, int r) { | ^~~~~ answer.code:59:6: note: ‘void build(int, int, int)’ previously defined here 59 | void build(int p, int l, int r) { | ^~~~~ answer.code:213:6: error: redefinition of ‘void chkmaxlr(int, int, int, int)’ 213 | void chkmaxlr(int p, int l, int r, int v) { | ^~~~~~~~ answer.code:71:6: note: ‘void chkmaxlr(int, int, int, int)’ previously defined here 71 | void chkmaxlr(int p, int l, int r, int v) { | ^~~~~~~~ answer.code:237:6: error: redefinition of ‘void chkminlr(int, int, int, int)’ 237 | void chkminlr(int p, int l, int r, int v) { | ^~~~~~~~ answer.code:95:6: note: ‘void chkminlr(int, int, int, int)’ previously defined here 95 | void chkminlr(int p, int l, int r, int v) { | ^~~~~~~~ answer.code:260:6: error: redefinition of ‘void dfs(int)’ 260 | void dfs(int p) { | ^~~ answer.code:118:6: note: ‘void dfs(int)’ previously defined here 118 | void dfs(int p) { | ^~~ answer.code:270:5: error: redefinition of ‘int op’ 270 | int op, l, r, h; | ^~ answer.code:128:5: note: ‘int op’ previously declared here 128 | int op, l, r, h; | ^~ answer.code:270:9: error: redefinition of ‘int l’ 270 | int op, l, r, h; | ^ answer.code:128:9: note: ‘int l’ previously declared here 128 | int op, l, r, h; | ^ answer.code:270:12: error: redefinition of ‘int r’ 270 | int op, l, r, h; | ^ answer.code:128:12: note: ‘int r’ previously declared here 128 | int op, l, r, h; | ^ answer.code:270:15: error: redefinition of ‘int h’ 270 | int op, l, r, h; | ^ answer.code:128:15: note: ‘int h’ previously declared here 128 | int op, l, r, h; | ^ answer.code:272:5: error: redefinition of ‘int main()’ 272 | int main() { | ^~~~ answer.code:130:5: note: ‘int main()’ previously defined here 130 | int main() { | ^~~~ answer.code: In function ‘int main()’: answer.code:273:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 273 | freopen("wall.in", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ answer.code:274:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 274 | freopen("wall.out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~