Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
35181 611434WZC [CSP-J2021]小熊的果篮 C++ 通过 100 33 MS 2764 KB 695 2021-12-13 13:53:14

Tests(10/10):


#include <bits/stdc++.h> using namespace std; const int MAXN=200010; int ID[MAXN],L[MAXN], R[MAXN],a[MAXN]= {-1}; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,x = 0; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); L[i] = i - 1; R[i] = i + 1; if (a[i] != a[i-1]) ID[x++] = i; } while (x) { int b = 0; for (int i = 0; i < x; ++i) { printf("%d ", ID[i]); int l = L[ID[i]]; int r = R[ID[i]]; L[r] = l; R[l] = r; if (r != n + 1 && a[ID[i]] == a[r] && a[r] != a[l]) ID[b++] = r; } x = b; printf("\n"); } return 0; }


测评信息: