Submission #862238

# Submission time Handle Problem Language Result Execution time Memory
862238 2023-10-17T19:30:00 Z AbdelmagedNour Volontiranje (COCI21_volontiranje) C++17
110 / 110
224 ms 92456 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n],lis[n]={};
	for(int i=0;i<n;i++)cin>>a[i];
	vector<int>dp;
	for(int i=0;i<n;i++){
		auto it=upper_bound(dp.begin(),dp.end(),a[i]);
		if(it==dp.end())dp.push_back(a[i]);
		else *it=a[i];
		lis[i]=upper_bound(dp.begin(),dp.end(),a[i])-dp.begin();
	}
	int mx=dp.size();
	vector<vector<int>>lvl(mx+1);
	for(int i=0;i<n;i++)lvl[lis[i]].push_back(i);
	for(int i=1;i<=mx;i++)reverse(lvl[i].begin(),lvl[i].end());
	vector<vector<int>>ans;
	vector<int>cur;
	while(!lvl[1].empty()||!cur.empty()){
		if(cur.empty())cur.push_back(lvl[1].back()),lvl[1].pop_back();
		else if(cur.size()==mx)ans.push_back(cur),cur.clear();
		else{
			int nxt=cur.size()+1;
			while(!lvl[nxt].empty()&&lvl[nxt].back()<cur.back())lvl[nxt].pop_back();
			if(!lvl[nxt].empty()&&a[lvl[nxt].back()]>a[cur.back()])cur.push_back(lvl[nxt].back()),lvl[nxt].pop_back();
			else cur.pop_back();
		}
	}
	cout<<ans.size()<<" "<<mx<<"\n";
	for(auto v:ans){
		for(auto x:v)cout<<x+1<<" ";
		cout<<"\n";
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   else if(cur.size()==mx)ans.push_back(cur),cur.clear();
      |           ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 460 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 460 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 600 KB Output is correct
28 Correct 0 ms 600 KB Output is correct
29 Correct 0 ms 600 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 448 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 460 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 600 KB Output is correct
28 Correct 0 ms 600 KB Output is correct
29 Correct 0 ms 600 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 448 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 76 ms 8532 KB Output is correct
48 Correct 84 ms 8948 KB Output is correct
49 Correct 100 ms 11908 KB Output is correct
50 Correct 178 ms 20420 KB Output is correct
51 Correct 41 ms 4860 KB Output is correct
52 Correct 204 ms 92456 KB Output is correct
53 Correct 224 ms 82348 KB Output is correct
54 Correct 211 ms 29776 KB Output is correct
55 Correct 149 ms 29776 KB Output is correct
56 Correct 2 ms 604 KB Output is correct
57 Correct 141 ms 16548 KB Output is correct
58 Correct 35 ms 4180 KB Output is correct
59 Correct 27 ms 3668 KB Output is correct
60 Correct 147 ms 16632 KB Output is correct
61 Correct 94 ms 10952 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 452 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct