# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533632 |
2022-03-06T17:45:57 Z |
CaroLinda |
Teams (CEOI11_tea) |
C++14 |
|
2500 ms |
52444 KB |
#include <bits/stdc++.h>
#define mk make_pair
#define lp(i,a,b) for(int i = a ; i < b; i++ )
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
using namespace std ;
int main(){
ios_base::sync_with_stdio(false );
cin.tie(0) ;
int N ;
cin >> N ;
vector<int> arr(N) , idx(N) ; iota(all(idx) , 0) ;
vector<int> corte(N) , mx(N) , tam(N) ;
for(auto &e : arr ) cin >> e ;
sort(all(idx),[&](int a, int b) { return arr[a] < arr[b] ; }) ;
vector<int> dp(N) ;
for(int i = 0 ; i < N ; i++){
tam[i] = i+1 ;
corte[i] = -1 ;
if( i+1 < arr[idx[i]] ){
dp[i] = mx[i] = 0 ;
if(i) mx[i] = max(mx[i] , mx[i-1]) ;
}
else{
dp[i] = mx[i] = max(1, mx[i-arr[idx[i]]]+1) ;
if(i) mx[i] = max(mx[i] , mx[i-1]) ;
}
}
vector<vector<int> > sweep(N+1, vector<int>()) ;
for(int i = 0 ; i < N ; i++ ) sweep[dp[i]].push_back(i) ;
for(int i = 1 ; i <= N ; i++ ){
sort(all(sweep[i]) , [&](int a, int b){
return a-arr[idx[a]] < b-arr[idx[b]] ;
}) ;
}
auto getPair = [&](int x){
return make_pair( tam[x]+x , x-tam[x] ) ;
} ;
vector<pair<int,int> > vec ;
vector<int> indices ;
for(int i = 2 ; i <= N ; i++ ){
int ptr = 0 ;
sort(all(sweep[i-1])) ;
vec.clear() ;
indices.clear() ;
for(auto e : sweep[i] ) {
while(ptr < sz(sweep[i-1]) && sweep[i-1][ptr] <= e-arr[idx[e]] ){
indices.push_back(sweep[i-1][ptr]) ;
vec.push_back(getPair(sweep[i-1][ptr++])) ;
}
tam[e] = N*2 ;
for(int a = 0 ; a < sz(vec) ; a++){
pair<int,int> p = vec[a] ;
int dx = abs(p.first-e) ;
int dy = abs(p.second-e) ;
if( ((dx+dy)>>1) < tam[e]){
tam[e] = (dx+dy)>>1 ;
corte[e] = indices[a] ;
}
}
}
}
vector<vector<int> > ans ;
int x = N-1 ;
while(x != -1){
ans.push_back(vector<int>()) ;
for(int i = corte[x]+1 ; i <= x ; i++ ) ans.back().push_back(idx[i]+1) ;
x = corte[x] ;
}
cout << sz(ans) <<"\n" ;
for(auto e : ans ){
cout << sz(e) <<" " ;
for(auto ee : e ) cout << ee <<" " ;
cout << "\n" ;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
280 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
588 KB |
Output is correct |
2 |
Correct |
3 ms |
588 KB |
Output is correct |
3 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
588 KB |
Output is correct |
2 |
Correct |
4 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2114 ms |
5644 KB |
Output is correct |
2 |
Correct |
36 ms |
5572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2310 ms |
6004 KB |
Output is correct |
2 |
Correct |
24 ms |
5572 KB |
Output is correct |
3 |
Correct |
2004 ms |
6640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2579 ms |
39220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2563 ms |
52444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2581 ms |
52024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |