Submission #734093

#TimeUsernameProblemLanguageResultExecution timeMemory
734093AmaarsaaPancake (NOI12_pancake)C++14
0 / 25
1076 ms272 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; ll n, ans, p, j, s; void Dfs(ll a[], ll moves) { if ( moves > ans) return; s = 0; for (ll i = 1; i <= n; i ++) { if ( a[i] <=a[i + 1]) s = 1; } if ( s == 0) { moves = min(moves, ans); return; } for (ll i = 1; i <= n; i ++) { reverse(a + i,a +n + 1); Dfs(a, moves + 1); reverse(a + i, a + n + 1); } return ; } int main() { ll i, t, r; cin >> t; while ( t --) { cin >> n; ans = 2 * n; ll a[n + 2]; vector < pair < ll, ll > > v; for (i = 1; i <= n; i ++) { cin >> a[i]; } Dfs(a, 0); cout <<ans << endl; } }

Compilation message (stderr)

pancake.cpp: In function 'int main()':
pancake.cpp:26:11: warning: unused variable 'r' [-Wunused-variable]
   26 |  ll i, t, r;
      |           ^
#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...