이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
const int maxVerrous = 1000*1000;
int nbVerrous, tailleOperation;
int reqUnlock[maxVerrous];
int cur[maxVerrous];
vector<pair<int, int>> tab;
int main()
{
scanf("%d%d", &nbVerrous, &tailleOperation);
tab.resize(nbVerrous);
for (int indVerrou = 0; indVerrou < nbVerrous; ++indVerrou) {
scanf("%d", &reqUnlock[indVerrou]);
tab[indVerrou] = {reqUnlock[indVerrou], indVerrou};
}
sort(tab.begin(), tab.end());
reverse(tab.begin(), tab.end());
vector<vector<int>> operations;
operations.reserve(100*1000);
vector<int> curOp(tailleOperation);
while (! tab.empty()) {
while ((! tab.empty()) && cur[tab.back().second] == reqUnlock[tab.back().second]) {
tab.pop_back();
}
if (tab.empty()) {
break;
}
int nbRestants = tab.size();
if (nbRestants < tailleOperation) {
printf("-1\n");
return 0;
}
for (int indPris = 0; indPris < tailleOperation; ++indPris) {
curOp[indPris] = tab[nbRestants - indPris - 1].second;
++cur[curOp[indPris]];
}
operations.push_back(curOp);
}
printf("%d\n", (int)(operations.size()));
for (auto op : operations) {
printf("1 ");
for (int choisi : op) {
printf("%d ", choisi+1);
}
printf("\n");
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |