답안 #1111522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111522 2024-11-12T09:15:27 Z DuongKiet Teams (CEOI11_tea) C++17
0 / 100
858 ms 27664 KB
#include <bits/stdc++.h>
#define N 1000005
#define inf 1e18
#define ll long long
#define ii pair <int, int>
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define SZ(x) (int) x.size()

const long long Mod = 1e9 + 7;

using namespace std;

int n;
struct cauthu{
    int c, id;
}a[N];
struct slteam{
    int c, id;
};
struct cmp{
    bool operator()(slteam &a, slteam &b){
        return a.c > b.c;
    }
};
void init(){

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i].c;
        a[i].id = i;
    }
    sort(a + 1, a + 1 + n, [&](cauthu a, cauthu b){
            return a.c > b.c;
        });
    vector <vector<int> > team;
    vector <int> maketeam;
    int cur = -1;
    for (int i = 1; i <= n; i++)
        maketeam.pb(a[i].id);
    while (!maketeam.empty()) {

        priority_queue<slteam, vector <slteam>, cmp> q;
        for (int i = 0; i < SZ(team); i++)
            q.push({SZ(team[i]), i});

        sort(all(maketeam), [&](int u, int v){return a[u].c < a[v].c;});

        while (a[maketeam.back()].c > SZ(maketeam) && !maketeam.empty()){
            slteam k = q.top();
            q.pop();
            team[k.id].pb(maketeam.back());
            q.push({SZ(team[k.id]), k.id});
            maketeam.pop_back();
            if (maketeam.empty()) break;
        }
        vector <int> nteam;
        int t = -1;
        if (!maketeam.empty())
        while (SZ(maketeam) >= a[maketeam.back()].c && !maketeam.empty()){
//            cout << "YES";
//            exit(0);
            if (t == -1) t = a[maketeam.back()].c;
            nteam.pb(maketeam.back());
            maketeam.pop_back();
            t--;
            if (t == 0 || maketeam.empty()) break;
        }
        team.pb(nteam);
    }
    cout << team.size() << '\n';
    for (vector <int> cur: team){
        cout << cur.size() << ' ';
        for (int x: cur)
            cout << x << " ";
        cout << '\n';
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #define task "DIVTEAM"
    if (fopen(task".inp", "r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    init();
    return 0;
}

Compilation message

tea.cpp: In function 'void init()':
tea.cpp:40:9: warning: unused variable 'cur' [-Wunused-variable]
   40 |     int cur = -1;
      |         ^~~
tea.cpp: In function 'int main()':
tea.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tea.cpp:88:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 20]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 100]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 4048 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 80005]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 4096 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 90003]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 858 ms 19432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 309 ms 24556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 271 ms 27664 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 1000000]
2 Halted 0 ms 0 KB -