답안 #905982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905982 2024-01-13T08:27:23 Z GrandTiger1729 Teams (CEOI11_tea) C++17
0 / 100
2500 ms 29020 KB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> solve(int t, vector<pair<int, int>> a)
{
    int n = a.size();
    vector<vector<int>> ans;
    ans.emplace_back();
    for (int i = 0; i < a[0].first; i++)
    {
        ans.back().push_back(a[i].second);
    }
    int l = a[0].first;
    for (int i = l; i < n; i++)
    {
        if (i - l >= a[l].first)
        {
            ans.emplace_back();
            while (l < i)
            {
                ans.back().push_back(a[l++].second);
            }
        }
        else if (i + a[i].first < l + a[l].first)
        {
            while (l < i && ans.back().size() < t)
            {
                ans.back().push_back(a[l++].second);
            }
        }
    }
    if (l < n && n - l >= a[l].first)
    {
        ans.emplace_back();
    }
    while (l < n)
    {
        ans.back().push_back(a[l++].second);
    }
    return ans;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[i] = make_pair(x, i);
    }
    sort(a.begin(), a.end(), greater<>());
    int l = a[0].first - 1, r = n;
    int t = solve(n, a).size();
    // while (l < r - 1)
    // {
    //     int mid = (l + r) / 2;
    //     (solve(mid, a).size() == t ? r : l) = mid;
    // }
    // auto ans = solve(r, a);
    int j = n;
    for (int i = l; i < n; i++)
    {
        if (solve(i, a).size() == t)
        {
            j = i;
            break;
        }
    }
    auto ans = solve(j, a);
    cout << ans.size() << '\n';
    for (auto &res : ans)
    {
        cout << res.size() << ' ';
        for (int &i : res)
        {
            cout << i + 1 << ' ';
        }
        cout << '\n';
    }
    return 0;
}

Compilation message

tea.cpp: In function 'std::vector<std::vector<int> > solve(int, std::vector<std::pair<int, int> >)':
tea.cpp:26:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |             while (l < i && ans.back().size() < t)
      |                             ~~~~~~~~~~~~~~~~~~^~~
tea.cpp: In function 'int main()':
tea.cpp:67:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |         if (solve(i, a).size() == t)
      |             ~~~~~~~~~~~~~~~~~~~^~~~
tea.cpp:56:29: warning: unused variable 'r' [-Wunused-variable]
   56 |     int l = a[0].first - 1, r = n;
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Incorrect 2 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1636 ms 2604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 2936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2511 ms 15696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 242 ms 27320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 29020 KB Output isn't correct
2 Halted 0 ms 0 KB -