제출 #672661

#제출 시각아이디문제언어결과실행 시간메모리
672661haxormanTeams (CEOI11_tea)C++14
0 / 100
251 ms20876 KiB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN = 1e6 + 7;

pair<int,int> arr[mxN];

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first;
        arr[i].second = i + 1;
    }
    sort(arr, arr + n);
    
    vector<vector<int>> ans = {{}};
    for (int i = 0; i < n; ++i) {
        ans.back().push_back(arr[i].second);
        if (ans.back().size() == arr[i].first) {
            ans.push_back({});
        }
    }
    
    /*
    for (auto vec : ans) {
        for (auto x : vec) {
            cout << x << ' ';
        }
        cout << "\n";
    }
    */

    if (!ans.back().size()) {
        ans.pop_back();
    }
    else if (ans.back().size() < arr[n - 1].first) {
        for (auto& vec : ans) {
            if (vec.size() + ans.back().size()) {
                for (auto x : ans.back()) {
                    vec.push_back(x);
                }
                break;
            }
        }
        ans.pop_back();
    }

    cout << ans.size() << "\n";
    for (auto vec : ans) {
        cout << vec.size() << ' ';
        for (auto x : vec) {
            cout << x << ' ';
        }
        cout << "\n";
    }
}

컴파일 시 표준 에러 (stderr) 메시지

tea.cpp: In function 'int32_t main()':
tea.cpp:23:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |         if (ans.back().size() == arr[i].first) {
      |             ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
tea.cpp:40:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     else if (ans.back().size() < arr[n - 1].first) {
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...