全部评论 1

  • 我直接模拟得 6060 分:

    #include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    using namespace std;
    void yz();
    signed main() {
        // freopen("Copy!.in", "r", stdin);
        // freopen("Copy!.out", "w", stdout);
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int t = 1;
        // cin >> t;
        while (t--) yz();
    }
    struct node {
        int val, id;
    };
    int n;
    list<node> a;
    vector<int> ans;
    bool Find(int x) {
        int l = 0, r = ans.size() - 1;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (ans[mid] == x) return 1;
            if (ans[mid] < x) l = mid + 1;
            else r = mid - 1;
        }
        return 0;
    }
    void yz() {
        cin >> n;
        for (int i = 1; i <= n; ++i) {
            int x;
            cin >> x;
            a.push_back({x, i});
        }
        while (!a.empty()) {
            ans.clear();
            for (auto i = a.begin(); i != a.end(); i++) {
                i--; auto i1 = i; i++;
                if (i -> val != i1 -> val || i == a.begin()) ans.push_back(i -> id);
            }
            for (auto i = a.begin(); i != a.end(); ) {
                i--; auto i1 = i; i++;
                if (Find(i -> id)) i = a.erase(i);
                else i++;
            }
            for (int i : ans)
                cout << i << " ";
            cout << "\n";
        }
    }
    

    看下面就行了(我的神奇专属格式)

    1周前 来自 浙江

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页