1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
using namespace std;
bool (int m, int n);
int main(int argc, char const *argv[]) { int m, n, k;cin >> m >> n >> k; for (int i = 0; i < k; i++) { bool valid = check(m,n); if (valid) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
bool (int m, int n) { int * stack = new int [n], stk = -1; int * store = new int [n], str = 0; for (int i = 0; i < n; i++) { cin >> store[i]; } bool valid = false; for (int topush = 1; topush <= n; topush++) { stack[++stk] = topush; if (stk==m) break; while (stk!=-1 && store[str]==stack[stk]) { stk--;str++; } } if (stk==-1) valid = true; delete [] stack; return valid; }
|
近期评论