QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567502 | #9313. Make Max | YFffffffff | Compile Error | / | / | C++23 | 1.9kb | 2024-09-16 12:21:07 | 2024-09-16 12:21:09 |
Judging History
你现在查看的是最新测评结果
- [2024-09-18 15:56:24]
- hack成功,自动添加数据
- (/hack/836)
- [2024-09-16 12:21:09]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-16 12:21:07]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
// 宏定义,用于简化循环
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
// 类型定义
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
// 随机数生成器和模数
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
// 随机数生成函数
int rnd(int x) {
return mrand() % x;
}
// 快速幂函数
ll powmod(ll a, ll b) {
ll res = 1;
a %= mod;
assert(b >= 0);
while (b) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
// 最大公约数函数
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
// 常量定义
const int N = 1010000;
int n;
// 全局变量
int stk[N], a[N], l[N], r[N];
ll ans;
map<int, int> cnt;
// 深度优先搜索函数
void dfs(int u, int dep) {
ans += dep;
if (l[u]) dfs(l[u], dep + (a[l[u]] != a[u]));
if (r[u]) dfs(r[u], dep + (a[r[u]] != a[u]));
}
// 构建函数
void build() {
int top = 0;
rep(i, 1, n + 1) l[i] = r[i] = 0;
rep(i, 1, n + 1) {
int k = top;
while (k > 0 && a[stk[k - 1]] < a[i]) --k;
if (k) r[stk[k - 1]] = i;
if (k < top) l[i] = stk[k];
stk[k++] = i;
top = k;
}
cnt.clear();
ans = 0;
dfs(stk[0], 0);
cout << ans << "\n";
}
// 解决问题的函数
void solve() {
cin >> n;
rep(i, 1, n + 1) cin >> a[i];
build();
}
// 主函数
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
for (cin >> _; _; _) {
solve();
}
}
Details
answer.code: In function ‘int main()’: answer.code:94:17: error: ‘_’ was not declared in this scope 94 | for (cin >> _; _; _) { | ^