QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#944#353627#8328. A Good ProblemFeiucup-team004Failed.2024-10-09 21:51:422024-10-09 21:51:44

详细

Extra Test:

Invalid Input

input:

jiangly

output:


result:

FAIL Expected integer, but "jiangly" found (stdin, line 1)

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#353627#8328. A Good Problemucup-team004#AC ✓3ms3920kbC++20939b2024-03-14 13:38:182024-03-14 13:38:19

answer

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    std::vector<std::pair<int, int>> ans;
    auto work = [&](auto self, int l, int r) -> void {
        if (r - l == 1) {
            return;
        }
        int m = (l + r) / 2;
        for (int i = 0; i < n; i++) {
            if (m <= b[i] && b[i] < r) {
                ans.emplace_back(2, i + 1);
            }
        }
        for (int i = l + 1; i < m; i++) {
            ans.emplace_back(1, i);
        }
        self(self, l, m);
        self(self, m, r);
    };
    work(work, 0, n + 1);

    std::cout << ans.size() << "\n";
    for (auto [x, y] : ans) {
        std::cout << x << " " << y << "\n";
    }

    return 0;
}