QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568653 | #9313. Make Max | beiweimd | Compile Error | / | / | C++14 | 1.9kb | 2024-09-16 17:30:35 | 2024-09-16 17:30:37 |
Judging History
你现在查看的是最新测评结果
- [2024-09-18 15:56:24]
- hack成功,自动添加数据
- (/hack/836)
- [2024-09-16 17:30:37]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-16 17:30:35]
- 提交
answer
#include <bits/stdc++.h>
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
#define int long long
int tt;
for (std::cin >> tt; tt--;) {
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::vector<int> stk;
int ans = 0;
auto work = [&]() {
if (size(stk) == 0 || a[stk[0]] == a[stk.back()]) return ;
std::reverse(stk.begin(), stk.end());
int p = stk[0], idx = 0;
while (idx < (int)size(stk) && a[p] == a[stk[idx]]) {
idx++;
}
for (int i = idx; i < (int)size(stk); ++i) {
ans += p - stk[i];
int x = a[stk[i]];
while (i < size(stk) && a[stk[i]] == x) {
++i;
}
--i;
}
};
for (int i = 0; i < n; ++i) {
if (size(stk) == 0 || a[stk.back()] >= a[i]) {
stk.push_back(i);
} else if (a[i] == a[stk[0]]) {
work();
stk.clear();
stk.push_back(i);
} else if (a[i] > a[stk[0]]) {
ans += i;
int x = a[i];
while (i < n && a[i] == x) {
i++;
}
--i;
work();
stk.clear();
stk.push_back(i);
} else {
while (size(stk) && a[stk.back()] < a[i]) {
int x = a[stk.back()];
while (size(stk) && x == a[stk.back()]) {
stk.pop_back();
}
ans += i - stk.back() - 1;
}
stk.push_back(i);
}
}
work();
std::cout << ans << '\n';
}
}
Details
answer.code: In lambda function: answer.code:17:17: error: ‘size’ was not declared in this scope 17 | if (size(stk) == 0 || a[stk[0]] == a[stk.back()]) return ; | ^~~~ answer.code:20:31: error: ‘size’ was not declared in this scope 20 | while (idx < (int)size(stk) && a[p] == a[stk[idx]]) { | ^~~~ answer.code:23:40: error: ‘size’ was not declared in this scope 23 | for (int i = idx; i < (int)size(stk); ++i) { | ^~~~ answer.code: In function ‘int main()’: answer.code:33:17: error: ‘size’ was not declared in this scope 33 | if (size(stk) == 0 || a[stk.back()] >= a[i]) { | ^~~~