|
5 | 5 |
|
6 | 6 | using namespace std; |
7 | 7 |
|
8 | | -const int N = 5002021; |
| 8 | +const int N = 202021; |
9 | 9 | bool vis[N * 50]; |
10 | | -int n, m, L, R, Sx, Sy, qn, q[N], x[N], y[N], vis1[N]; |
| 10 | +int n, m, L, R, Sx, Sy, qn, q[N], x[N], y[N], vis1[N],stk[N]; |
11 | 11 |
|
12 | 12 | int _abs(int x) { |
13 | 13 | return (x < 0) ? (-x) : x; |
@@ -101,20 +101,31 @@ int main(int argc, char* argv[]) { |
101 | 101 |
|
102 | 102 | // Check row completion constraint |
103 | 103 | memset(vis1, 0, sizeof(vis1)); |
| 104 | + int top=0; |
104 | 105 | for (int i = 1; i <= cnt; i++) { |
105 | 106 | if (y[i] < L || y[i] > R) continue; |
106 | 107 | if (vis1[x[i]]) continue; |
107 | 108 | vis1[x[i]] = 1; |
| 109 | + stk[++top]=x[i]; |
108 | 110 | // When first entering row x[i]'s required area, must complete all required cells in that row |
109 | 111 | for (int j = L; j <= R; j++) { |
110 | 112 | int idx = j - L + i; |
111 | 113 | if (idx > cnt) break; |
112 | | - if ((y[idx] < L || y[idx] > R) && x[idx] == x[i]) { |
| 114 | + if(x[idx] != x[i]) |
| 115 | + quitf(_wa, "Row %d: after entering required area, cannot leave before completing all required cells", x[i]); |
| 116 | + if (y[idx] < L || y[idx] > R) { |
113 | 117 | quitf(_wa, "Row %d: after entering required area, cannot leave before completing all required cells", x[i]); |
114 | 118 | } |
115 | 119 | } |
116 | 120 | } |
117 | 121 |
|
| 122 | + if(top!=n) |
| 123 | + quitf(_wa, "Required cell is not visited"); |
| 124 | + int nw=1; |
| 125 | + for(int i=1;i<=qn;i++){ |
| 126 | + while(nw<=top && q[i]!=stk[nw])++nw; |
| 127 | + if(stk[nw]!=q[i])quitf(_wa, "Your clearance sequence does not contain the required subsequence"); |
| 128 | + } |
118 | 129 | // Calculate score (0-10 points) |
119 | 130 | double points = 0; |
120 | 131 | if (cnt <= mxstp) { |
|
0 commit comments