QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#449590 | #8301. Hold the Line | PetroTarnavskyi# | Compile Error | / | / | C++20 | 1.7kb | 2024-06-21 15:07:31 | 2024-06-21 15:07:31 |
Judging History
answer
//#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int INF = 1e9 + 47;
int f(const set<int>& s, int h)
{
auto it = s.lower_bound(h);
int res = INF;
if (it != s.end())
res = min(res, *it - h);
if (it != s.begin())
res = min(res, h - *prev(it));
return res;
}
struct SegTree
{
int n;
vector<set<int>> t;
void init(int _n)
{
n = 1;
while (n < _n)
n *= 2;
t.clear();
t.resize(2 * n - 1);
}
void upd(int v, int tl, int tr, int pos, int h)
{
t[v].insert(h);
if (tl == tr - 1)
{
return;
}
int tm = (tl + tr) / 2;
upd(2 * v + 1, tl, tm, pos, h);
upd(2 * v + 2, tm, tr, pos, h);
}
int query(int v, int tl, int tr, int l, int r, int h)
{
if (r <= tl || tr <= l)
return INF;
if (l <= tl && tr <= r)
return f(t[v], h);
int tm = (tl + tr) / 2;
return min(query(2 * v + 1, tl, tm, l, r, h), query(2 * v + 2, tm, tr, l, r, h));
}
} st;
void solve()
{
int n, m;
cin >> n >> m;
st.init(n);
while (m--)
{
int t;
cin >> t;
if (t == 0)
{
int x, h;
cin >> x >> h;
x--;
st.upd(0, 0, st.n, x, h);
}
else
{
int l, r, h;
cin >> l >> r >> h;
l--;
int ans = st.query(0, 0, st.n, l, r, h);
cout << (ans == INF ? -1 : ans) << "\n";
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
Details
answer.code:14:9: error: ‘vector’ does not name a type 14 | typedef vector<int> VI; | ^~~~~~ answer.code:15:9: error: ‘pair’ does not name a type 15 | typedef pair<int, int> PII; | ^~~~ answer.code:20:13: error: ‘set’ does not name a type 20 | int f(const set<int>& s, int h) | ^~~ answer.code:20:16: error: expected ‘,’ or ‘...’ before ‘<’ token 20 | int f(const set<int>& s, int h) | ^ answer.code: In function ‘int f(int)’: answer.code:22:19: error: ‘s’ was not declared in this scope 22 | auto it = s.lower_bound(h); | ^ answer.code:22:33: error: ‘h’ was not declared in this scope 22 | auto it = s.lower_bound(h); | ^ answer.code:25:23: error: ‘min’ was not declared in this scope 25 | res = min(res, *it - h); | ^~~ answer.code:27:37: error: ‘prev’ was not declared in this scope 27 | res = min(res, h - *prev(it)); | ^~~~ answer.code:1:1: note: ‘std::prev’ is defined in header ‘<iterator>’; did you forget to ‘#include <iterator>’? +++ |+#include <iterator> 1 | //#include <bits/stdc++.h> answer.code:27:23: error: ‘min’ was not declared in this scope 27 | res = min(res, h - *prev(it)); | ^~~ answer.code: At global scope: answer.code:34:16: error: ‘set’ was not declared in this scope 34 | vector<set<int>> t; | ^~~ answer.code:1:1: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? +++ |+#include <set> 1 | //#include <bits/stdc++.h> answer.code:34:16: error: ‘set’ was not declared in this scope 34 | vector<set<int>> t; | ^~~ answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:16: error: ‘set’ was not declared in this scope answer.code:34:16: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? answer.code:34:9: error: ‘vector’ does not name a type 34 | vector<set<int>> t; | ^~~~~~ answer.code: In member function ‘void SegTree::init(int)’: answer.code:40:17: error: ‘t’ was not declared in this scope 40 | t.clear(); | ^ answer.code: In member function ‘void SegTree::upd(int, int, int, int, int)’: answer.code:45:17: error: ‘t’ was not declared in this scope 45 | t[v].insert(h); | ^ answer.code: In member function ‘int SegTree::query(int, int, int, int, int, int)’: answer.code:59:34: error: ‘t’ was not declared in this scope 59 | return f(t[v], h); | ^ answer.code:61:24: error: ‘min’ was not declared in this scope 61 | return min(query(2 * v + 1, tl, tm, l, r, h), query(2 * v + 2, tm, tr, l, r, h)); | ^~~ answer.code: In function ‘void solve()’: answer.code:68:9: error: ‘cin’ was not declared in this scope 68 | cin >> n >> m; | ^~~ answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | //#include <bits/stdc++.h> answer.code:87:25: error: ‘cout’ was not declared in this scope 87 | cout << (ans == INF ? -1 : ans) << "\n"; | ^~~~ answer.code:87:25: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? answer.code: In function ‘int main()’: answer.code:94:9: error: ‘ios’ has not been declared 94 | ios::sync_with_stdio(0); | ^~~ an...