Submission #896972

#TimeUsernameProblemLanguageResultExecution timeMemory
896972AndrijaMPancake (NOI12_pancake)C++14
12 / 25
15 ms348 KiB
#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=1; 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)

pancake.cpp: In function 'int main()':
pancake.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int i=1;i<v.size();i++)
      |                         ~^~~~~~~~~
pancake.cpp:40:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                     for(int j=i;j<v.size();j++)
      |                                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...