답안 #532450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532450 2022-03-02T22:05:17 Z definitelynotmee Teams (CEOI11_tea) C++
80 / 100
291 ms 73548 KB
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;



int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    vector<int> o(n);
    iota(all(o),0);
    sort(all(o),[&](int a, int b){
        return v[a] > v[b];
    });

    matrix<int> resp;
    int start = 0;
    while(start < n && n-start>=v[o[start]]){
        resp.push_back({});
        for(int i = 0; i < v[o[start]]; i++){
            resp.back().push_back(o[i+start]);
        }
        start+=v[o[start]];
    };
    reverse(all(resp));
    for(int i = 0; i < (int)resp.size()-1; i++){
        assert(resp[i].size() <= resp[i+1].size());
    }
    while(start < n && n-start<v[o[start]]){
        int ptr = 0;
        while(start < n && n-start<v[o[start]] &&ptr < resp.size() && (ptr == 0 || resp[ptr-1].size() > resp[ptr].size())){
            resp[ptr].push_back(o[start]);
            ptr++;
            start++;
        }
    }
    if(start < n){
        resp.push_back({});
        while(start < n)
            resp.back().push_back(o[start]), start++;
    }
    cout << resp.size() << '\n';
    assert(resp.size());
    int tot =0;
    for(vector<int>& i : resp){
        tot+=i.size();
    }
    assert(tot == n);
    for(vector<int>& i : resp){
        cout << i.size() << ' ';
        assert(i.size());
        for(int j : i){
            assert(i.size() >= v[j]);
            cout << j+1 << ' ';
        }
        cout << '\n';
    }


    return 0;

}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:55:54: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         while(start < n && n-start<v[o[start]] &&ptr < resp.size() && (ptr == 0 || resp[ptr-1].size() > resp[ptr].size())){
      |                                                  ~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from tea.cpp:1:
tea.cpp:77:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   77 |             assert(i.size() >= v[j]);
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 456 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 2220 KB Output is correct
2 Correct 14 ms 2124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2380 KB Output is correct
2 Correct 14 ms 2252 KB Output is correct
3 Correct 19 ms 2368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 15652 KB Output is correct
2 Correct 137 ms 18680 KB Output is correct
3 Correct 153 ms 19900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 19880 KB Output is correct
2 Correct 291 ms 73548 KB Output is correct
3 Correct 188 ms 22544 KB Output is correct
4 Correct 218 ms 21832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 19860 KB Output is correct
2 Correct 181 ms 19868 KB Output is correct
3 Correct 194 ms 20580 KB Output is correct
4 Correct 259 ms 24940 KB Output is correct