답안 #862228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
862228 2023-10-17T18:52:28 Z Ahmed_Solyman Volontiranje (COCI21_volontiranje) C++14
0 / 110
1 ms 600 KB
/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
vector<int> LIS(vector<int>arr){
	vector<int>v;
	for(auto i:arr){
		if(!v.size()){
			v.push_back(i);
		}
		else{
			if(v.back()<i){
				v.push_back(i);
			}
			else{
				v[(ub(all(v),i)-v.begin())]=i;
			}
		}
	}
	return v;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    #endif
    fast
    int n;cin>>n;
    vector<int>arr(n);
    map<int,int>mp;
    int j=1;
    for(auto &i:arr)cin>>i,mp[i]=j++;
    int lis=LIS(arr).size();
	int cnt=0;
	vector<vector<int>>ans;
	while(1){
		vector<int>v=LIS(arr);
		map<int,int>idx;
		for(int i=0;i<arr.size();i++){
			idx[arr[i]]=i;
		}
		if(v.size()==lis){
			cnt++;
			ans.push_back(v);
			for(int i=lis-1;i>=0;i--){
				arr.erase(arr.begin()+idx[v[i]]);
			}
		}
		else{
			break;
		}
	}
	cout<<cnt<<" "<<lis<<endl;
	for(auto i:ans){
		for(auto j:i)cout<<mp[j]<<" ";
		cout<<endl;
	}
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:75:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   for(int i=0;i<arr.size();i++){
      |               ~^~~~~~~~~~~
Main.cpp:78:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   78 |   if(v.size()==lis){
      |      ~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -