TopCoder

User's AC Ratio

33.3% (1/3)

Submission's AC Ratio

14.3% (1/7)

Tags

Description

Input Format

本題是互動題,不用引入任何標頭檔,程式碼請勿輸入或輸出任何東西。如果你輸入了任何東西可能會導致各種不可預期的結果。

Output Format

Sample Input 1

5 2
2 4 3 1 5
1 4
1 5

Sample Output 1

本題沒有輸出

Hints

以下是一個可以編譯(但一定不會答對)的範例程式碼:

#include <vector>

bool compare_subsets(const std::vector<int>& a, const std::vector<int>& b);

namespace {
    // 如果需要,你可以在這裡宣告全域變數
    int len;
}

void init(int n) {
    len = n;
}

std::vector<int> range_MWIS_query(int l, int r) {
    return {r};
}

Problem Source

以下是範例 grader。
grader 輸出如題本敘述。

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cassert>

// Functions to be implemented in the solution.
void init(int n);
std::vector <int> range_MWIS_query(int l, int r);

namespace {
    long long n, q;
    long long w[2002];
    long long query_left[2002], query_right[2002];
    long long query_count, Q_init, Q_query;
    bool vis[2002];
    std::vector<int> sol[2002];
    void wrong_answer(const std::string &msg) {
        std::cout << "Wrong Answer: " << msg << std::endl;
        exit(0);
    }
    void check_valid_set(const std::vector<int> &a) {
        for (int id : a) {
            if (!(1 <= id && id <= n))
                wrong_answer("Invalid vertex number: " + std::to_string(id));
            if (vis[id])
                wrong_answer("Duplicated vertex number: " + std::to_string(id));
            vis[id] = true;
        }
        for (int id : a)
            vis[id] = false;
    }
    long long get_subset_sum(const std::vector <int> a) {
        long long res = 0;
        for (int id : a)
            res += w[id];
        return res;
    }
}

bool compare_subsets(const std::vector<int>& a, const std::vector<int>& b) {
    check_valid_set(a);
    check_valid_set(b);
    return get_subset_sum(a) < get_subset_sum(b);
}

int main() {
    std::cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        std::cin >> w[i];
    }
    for (int i = 1; i <= q; ++i) {
        std::cin >> query_left[i] >> query_right[i];
    }
    init(n);
    Q_init = (query_count + n - 1) / n;
    query_count = 0;


    for (int i = 1; i <= q; ++i) {
        sol[i] = range_MWIS_query(query_left[i], query_right[i]);
        Q_query = std::max(Q_query, query_count);
        query_count = 0;
    }

    for (int i = 1; i <= q; ++i) {
        std::cout << (int)sol[i].size() << std::endl;
        for (int j = 0; j < (int)sol[i].size(); ++j) {
            if (j > 0)
                std::cout << " ";
            std::cout << sol[i][j];
        }
        std::cout << std::endl;
    }
    std::cout << "Accepted: " << Q_init << " " << Q_query << std::endl;

    return 0;
}

Subtasks

No. Testdata Range Score
1 0~10 16
2 11~20 11
3 0~50 73

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1 3
1 1000 65536 65536 1 3
2 1000 65536 65536 1 3
3 1000 65536 65536 1 3
4 1000 65536 65536 1 3
5 1000 65536 65536 1 3
6 1000 65536 65536 1 3
7 1000 65536 65536 1 3
8 1000 65536 65536 1 3
9 1000 65536 65536 1 3
10 1000 65536 65536 1 3
11 1000 65536 65536 2 3
12 1000 65536 65536 2 3
13 1000 65536 65536 2 3
14 1000 65536 65536 2 3
15 1000 65536 65536 2 3
16 1000 65536 65536 2 3
17 1000 65536 65536 2 3
18 1000 65536 65536 2 3
19 1000 65536 65536 2 3
20 1000 65536 65536 2 3
21 1000 65536 65536 3
22 1000 65536 65536 3
23 1000 65536 65536 3
24 1000 65536 65536 3
25 1000 65536 65536 3
26 1000 65536 65536 3
27 1000 65536 65536 3
28 1000 65536 65536 3
29 1000 65536 65536 3
30 1000 65536 65536 3
31 1000 65536 65536 3
32 1000 65536 65536 3
33 1000 65536 65536 3
34 1000 65536 65536 3
35 1000 65536 65536 3
36 1000 65536 65536 3
37 1000 65536 65536 3
38 1000 65536 65536 3
39 1000 65536 65536 3
40 1000 65536 65536 3
41 1000 65536 65536 3
42 1000 65536 65536 3
43 1000 65536 65536 3
44 1000 65536 65536 3
45 1000 65536 65536 3
46 1000 65536 65536 3
47 1000 65536 65536 3
48 1000 65536 65536 3
49 1000 65536 65536 3
50 1000 65536 65536 3