Submission #773308

# Submission time Handle Problem Language Result Execution time Memory
773308 2023-07-04T20:51:59 Z NK_ Teams (CEOI11_tea) C++17
0 / 100
206 ms 38448 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
 
using namespace std;
 
#define nl '\n'
#define f first
#define s second
#define mp make_pair
 
#define sz(x) int(x.size())
 
using pi = pair<int, int>;
template<class T> using V = vector<T>;
 
int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;
	V<int> A(N); for(auto& x : A) cin >> x;
 
	V<pi> B; for(int i = 0; i < N; i++) B.push_back(mp(A[i], i));
	sort(rbegin(B), rend(B));
 
	V<V<int>> C;
	multiset<pi> siz;
	for(int i = 0; i < N; i++) {
		int left = N - i;
		if (left < B[i].first) {
			int idx = -(*begin(siz)).s;
			// cout << idx << " " << sz(C) - 1 << endl;
			assert(idx == (sz(C) - 1));
			// assert(sz(C[idx])+1 >= B[i].first);
			siz.erase(begin(siz));
 
			C[idx].push_back(B[i].second);
 
			siz.insert(mp(sz(C[idx]), -idx));
		} else {
			int r = i + B[i].first;
			
			C.push_back({});
			for(int x = i; x < r; x++) C.back().push_back(B[x].second);
			
			siz.insert(mp(sz(C.back()), -sz(C) + 1));
			
			i = r - 1; 
		}
	}
 
	int mx = 0; for(auto v : C) mx = max(mx, sz(v));
	// cout << mx << nl;
 
	cout << sz(C) << nl;
	for(auto v : C) {
		cout << sz(v) << " ";
		for(auto x : v) cout << x + 1 << " ";
		cout << nl;
	}
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Runtime error 2 ms 724 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 3408 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3500 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 125 ms 25388 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 206 ms 33644 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 196 ms 38448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -