QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#648305 | #8749. 贸易 | Xwc | Compile Error | / | / | C++14 | 1.9kb | 2024-10-17 18:12:51 | 2024-10-17 18:12:57 |
Judging History
This is the latest submission verdict.
- [2024-10-17 18:12:57]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-17 18:12:51]
- Submitted
answer
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef double ff;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef pair<ll, ll> pii;
const int N = 5e5 + 10, M = 1e7, base = 131;
typedef struct node {
int x, y, id;
} node;
lln, q, a[N], c[N], tr[N];
vector<int> p[N];
vector<node> all, qq;
int lowbit(int x)
{
return x & (-x);
}
ll query(int k)
{
ll sum = 0;
while( k ) {
sum += tr[k];
k -= lowbit(k);
}
return sum;
}
void add(int k, int x)
{
while( k <= n ) {
tr[k] += x;
k += lowbit(k);
}
}
bool cmp(node u1, node u2)
{
if(u1.y != u2.y) return u1.y < u2.y;
else return u1.x < u2.x;
}
bool cmp1(node u1, node u2)
{
if(u1.y != u2.y) return u1.y > u2.y;
}
void solve()
{
cin >> n >> q;
for(int i = 1; i <= n; i ++ ) cin >> a[i];
for(int i = 1; i <= n; i ++ ) cin >> c[i];
for(int i = 1; i <= n; i ++ ) {
if(a[i] == 0) {
p[c[i]].push_back(i);
} else {
if(p[c[i]].size()) {
all.push_back({p[c[i]].back(), i});
p[c[i]].pop_back();
}
}
}
sort(all.begin(), all.end(), cmp1);
// for(auto e : all) {
// cout << e.x << ' ' << e.y << '\n';
// }
for(int i = 1; i <= q; i ++ ) {
int l, r;
cin >> l >> r;
qq.push_back({l, r, i});
}
sort(qq.begin(), qq.end(), cmp);
// for(auto e : qq) {
// cout << e.x << ' ' << e.y << '\n';
// }
vector<ll> ans(q + 1);
ll m = 0;
for(int i = 0; i < qq.size(); i ++ ) {
int l = qq[i].x, r = qq[i].y, id = qq[i].id;
while(all.size() && all.back().y <= r) {
add(all.back().x, 1);
all.pop_back();
m ++;
}
ans[id] = m - query(l - 1);
}
for(int i = 1; i <= q; i ++ ) {
cout << ans[i] << '\n';
}
}
int main()
{
fastio;
int t = 1;
// cin >> t;
while( t -- ) solve();
}
Details
answer.code:18:1: error: ‘lln’ does not name a type; did you mean ‘ll’? 18 | lln, q, a[N], c[N], tr[N]; | ^~~ | ll answer.code: In function ‘ll query(int)’: answer.code:33:24: error: ‘tr’ was not declared in this scope; did you mean ‘tm’? 33 | sum += tr[k]; | ^~ | tm answer.code: In function ‘void add(int, int)’: answer.code:41:21: error: ‘n’ was not declared in this scope 41 | while( k <= n ) { | ^ answer.code:42:17: error: ‘tr’ was not declared in this scope; did you mean ‘tm’? 42 | tr[k] += x; | ^~ | tm answer.code: In function ‘void solve()’: answer.code:62:16: error: ‘n’ was not declared in this scope 62 | cin >> n >> q; | ^ answer.code:62:21: error: ‘q’ was not declared in this scope; did you mean ‘qq’? 62 | cin >> n >> q; | ^ | qq answer.code:64:46: error: ‘a’ was not declared in this scope 64 | for(int i = 1; i <= n; i ++ ) cin >> a[i]; | ^ answer.code:65:46: error: ‘c’ was not declared in this scope 65 | for(int i = 1; i <= n; i ++ ) cin >> c[i]; | ^ answer.code:68:20: error: ‘a’ was not declared in this scope 68 | if(a[i] == 0) { | ^ answer.code:69:27: error: ‘c’ was not declared in this scope 69 | p[c[i]].push_back(i); | ^ answer.code:71:30: error: ‘c’ was not declared in this scope 71 | if(p[c[i]].size()) { | ^ answer.code:72:46: error: no matching function for call to ‘std::vector<node>::push_back(<brace-enclosed initializer list>)’ 72 | all.push_back({p[c[i]].back(), i}); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/queue:63, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157, from answer.code:1: /usr/include/c++/13/bits/stl_vector.h:1278:7: note: candidate: ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = node; _Alloc = std::allocator<node>; value_type = node]’ 1278 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1278:35: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<node>::value_type&’ {aka ‘const node&’} 1278 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:1295:7: note: candidate: ‘void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = node; _Alloc = std::allocator<node>; value_type = node]’ 1295 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1295:30: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::vector<node>::value_type&&’ {aka ‘node&&’} 1295 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ answer.code: In function ‘bool cmp1(node, node)’: answer.code:57:1: warning: control reaches end of non-void function [-Wreturn-type] 57 | } | ^