답안 #686474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
686474 2023-01-25T10:25:02 Z willychan Volontiranje (COCI21_volontiranje) C++14
50 / 110
1000 ms 89340 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds




int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;cin>>n;
	vector<int> arr;
	int inp[n];
	for(int i=0;i<n;i++){
		cin>>inp[i];
		int b = upper_bound(arr.begin(),arr.end(),inp[i])-arr.begin();
		if(b>=arr.size()) arr.push_back(inp[i]);
		else{
			arr[b] = inp[i];
		}
	}
	int k = arr.size();
	int g = k;
	vector<vector<int> > ans(k);
	bool take[n+1]={0};
	while(g==k){	
		int prev[n+1]={0};
		arr.clear();
		for(int i=0;i<n;i++){
			if(take[inp[i]]) continue;
			int b = upper_bound(arr.begin(),arr.end(),inp[i])-arr.begin();
			if(b>=arr.size()) arr.push_back(inp[i]);
			else{
				arr[b] = inp[i];
			}
			if(b) prev[inp[i]] = arr[b-1];
		}
		if((g=arr.size())!=k) break;
		int cur = arr.back();
		for(int m=k-1;m>=0;m--){
			ans[m].push_back(cur);
			take[cur]=1;
			cur = prev[cur];
		}
	}
	int p = ans[0].size();
	cout<<p<<" "<<k<<"\n";
	vector<vector<int> > realans(p);
	int convert[n+1];
	for(int i=0;i<n;i++){
		convert[inp[i]]=i+1;
	}
	for(int i=0;i<p;i++){
		for(int j=0;j<k;j++){
			realans[i].push_back(convert[ans[j][i]]);
		}
	}
	sort(realans.begin(),realans.end());
	for(auto v : realans){
		for(auto i : v){
			cout<<i<<" ";
		}
		cout<<"\n";
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:18:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(b>=arr.size()) arr.push_back(inp[i]);
      |      ~^~~~~~~~~~~~
Main.cpp:33:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if(b>=arr.size()) arr.push_back(inp[i]);
      |       ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 320 KB Output is correct
35 Correct 2 ms 316 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 0 ms 320 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 324 KB Output is correct
42 Correct 0 ms 316 KB Output is correct
43 Correct 0 ms 320 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 320 KB Output is correct
35 Correct 2 ms 316 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 0 ms 320 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 324 KB Output is correct
42 Correct 0 ms 316 KB Output is correct
43 Correct 0 ms 320 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 100 ms 6804 KB Output is correct
48 Correct 106 ms 7128 KB Output is correct
49 Correct 153 ms 8868 KB Output is correct
50 Correct 250 ms 15480 KB Output is correct
51 Correct 54 ms 3724 KB Output is correct
52 Correct 276 ms 89340 KB Output is correct
53 Execution timed out 1057 ms 15848 KB Time limit exceeded
54 Halted 0 ms 0 KB -