Click in problem name to go uHunt website!
Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss120 - | Accepted | C++11 | 0.000 | 0.000 | 2109 | 29 mins ago |
#include<bits/stdc++.h>
#define int long long
#define file_in(f) freopen(f,"r",stdin)
#define file_out(f) freopen(f,"w",stdout)
#define fast_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define For(i, a, b) for(int i=a; i<=b; i++)
#define Dow(i, a, b) for(int i=a; i>=b; i--)
#define Sort(a) sort(a.begin(),a.end());
#define Sort_r(a) sort(a.rbegin(),a.rend());
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second
#define oo LLONG_MAX
#define max_double DBL_MAX
#define N 1000111
//to_string : convert int to string
//stoi : convert string to int
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
int t, n;
int32_t main(){
fast_IO
//file_in("in.txt");
//file_out("out.txt");
string line;
while(getline(cin, line)){
int a[line.size()+1];
string s="";
line += ' ';
int n= 0;
For(i, 0, line.size()-1)
if (line[i]==' '){
a[++n]= stoi(s);
s="";
}
else
s += line[i];
line.erase(line.size()-1, 1);
cout<<line<<"\n";
For(k, 1, n){
int i_max= 1, v_max= a[1];
For(i, 1, n-k+1)
if (v_max < a[i]){
v_max = a[i];
i_max = i;
}
if (i_max != n-k+1){
cout<<(n - i_max + 1 != n ? to_string(n - i_max + 1)+" " : "")<<k<<" ";
reverse(a+1, a+1+i_max);
reverse(a+1, a+1+ (n-k+1));
}
}
cout<<"0\n";
}
}
No comments:
Post a Comment