# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896961 | AndrijaM | Pancake (NOI12_pancake) | C++14 | 16 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
int n;
while(t--)
{
cin>>n;
vector<int>v;
for(int i=0;i<n;i++)
{
int num;
cin>>num;
v.push_back(num);
}
reverse(v.begin(),v.end());
vector<int>s;
s=v;
sort(s.begin(),s.end());
if(v==s)
{
cout<<0<<endl;
}
else
{
int ans=0;
vector<int>pom;
for(int i=1;i<v.size();i++)
{
if(v[i]>v[i-1])
{
for(int j=i-1;j>=0;j--)
{
pom.push_back(v[j]);
}
for(int j=i;j<v.size();j++)
{
pom.push_back(v[j]);
}
if(pom==s)
{
ans=1;
break;
}
else
{
ans=2;
break;
}
}
}
cout<<ans<<endl;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |