/**
* author: longvu
* created: 11/01/22 09:56:51
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int naxn = (int)(12);
const int naxm = (int)(109001);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
if (y > x) {x = y; return true;}
return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
if (y < x) {x = y; return true;}
return false;
}
#define Fi first
#define Se second
bitset<naxm> a[naxn], dp[naxn], ans;
pair<int, int> tr[naxn][naxm];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= 10; ++i) {
for (int j = 1; j <= n; ++j) {
char c;
cin >> c;
a[i][j] = (c == 'X' ? 1 : 0);
}
}
dp[10][0] = 1;
for (int j = 0; j < n; ++j) {
if (dp[10][j] && !a[10][j + 1] && !dp[10][j + 1]) {
dp[10][j + 1] = 1;
tr[10][j + 1] = {10, 0};
}
if (dp[1][j] && !a[1][j + 1] && !dp[1][j + 1]) {
dp[1][j + 1] = 1;
tr[1][j + 1] = {1, 1};
}
if (!j) {
continue;
}
for (int i = 1; i <= 10; ++i) {
if (dp[i][j]) {
if (i < 10 && !a[i + 1][j + 1] && !dp[i + 1][j + 1]) {
dp[i + 1][j + 1] = 1;
tr[i + 1][j + 1] = {i, 0};
}
if (i > 1 && !a[i - 1][j + 1] && !dp[i - 1][j + 1]) {
dp[i - 1][j + 1] = 1;
tr[i - 1][j + 1] = {i, 1};
}
}
}
}
int i = 1, j = n;
for (int e = 1; e <= 10; ++e) {
if (dp[e][n]) {
i = e;
}
}
while (j) {
ans[j - 1] = tr[i][j].Se;
i = tr[i][j].Fi;
j--;
}
// for (int i = 0; i < n; ++i) {
// cout << ans[i] << " ";
// }
// cout << '\n';
vector<pair<int, int>> anstr;
for (int i = 2; i <= n; ++i) {
if (ans[i]) {
int r = i;
while (r + 1 <= n && ans[r + 1]) {
r++;
}
anstr.push_back({i - 1, r - 1});
i = r;
}
}
cout << sz(anstr) << '\n';
for (auto [x, y] : anstr) {
cout << x << " " << y << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
Pressing button after game end |
2 |
Incorrect |
1 ms |
468 KB |
Crashed with an obstacle |
3 |
Incorrect |
0 ms |
468 KB |
Pressing button after game end |
4 |
Incorrect |
1 ms |
596 KB |
Pressing button after game end |
5 |
Incorrect |
1 ms |
1108 KB |
Pressing button after game end |
6 |
Incorrect |
2 ms |
1364 KB |
Pressing button after game end |
7 |
Incorrect |
7 ms |
3540 KB |
Pressing button after game end |
8 |
Incorrect |
16 ms |
8148 KB |
Pressing button after game end |
9 |
Incorrect |
24 ms |
12104 KB |
Pressing button after game end |
10 |
Incorrect |
35 ms |
16720 KB |
Pressing button after game end |