# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734222 | 2023-05-02T05:24:15 Z | Amaarsaa | Pancake (NOI12_pancake) | C++14 | 1000 ms | 212 KB |
#include<bits/stdc++.h> using namespace std; using ll = int; 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) { ans = 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]; for (i = 1; i <= n; i ++) { cin >> a[i]; } Dfs(a, 0); cout <<ans << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 459 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |