# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162594 | _qVp_ | Jetpack (COCI16_jetpack) | C++14 | 39 ms | 12296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int md = 1e5 + 10;
bool vis[15][md][5];
string s[15];
int n;
int ans[md];
void print() {
int len = (ans[1] == 1);
/*for(int i = 1; i <= n; i++)
cout << ans[i] << " ";
cout << endl;*/
for(int i = 2; i <= n; i++) {
if (ans[i] && ans[i - 1])
ans[i] += ans[i - 1];
if (ans[i] == 1)
len++;
}
cout << len << '\n';
for(int i = 1; i <= n; i++) {
if (ans[i] == 1)
cout << i - 1 << " ";
if (ans[i] != 0 && ans[i + 1] == 0)
cout << ans[i] << '\n';
}
exit(0);
}
void dfs(int x, int y, int ss) {
vis[x][y][ss] = true;
//cout << x << " " << y << " " << ss << endl;
if (y == n)
print();
if (x == 10) {
if (s[x][y + 1] == '.' && !vis[x][y + 1][0]) {
//ans[y] = 1;
dfs(x, y + 1, 0);
} if (s[x - 1][y + 1] == '.' && !vis[x - 1][y + 1][1]) {
ans[y] = 1;
dfs(x - 1, y + 1, 1);
ans[y] = 0;
}
} else if (x == 1) {
if (s[x][y + 1] == '.' && !vis[x][y + 1][1]) {
ans[y] = 1;
dfs(x, y + 1, 1);
ans[y] = 0;
}
if (s[x + 1][y + 1] == '.' && !vis[x + 1][y + 1][0]) {
dfs(x + 1, y + 1, 0);
}
} else {
//up
if (s[x - 1][y + 1] == '.' && !vis[x - 1][y + 1][1]) {
ans[y] = 1;
dfs(x - 1, y + 1, 1);
ans[y] = 0;
}
//down
if (s[x + 1][y + 1] == '.' && !vis[x + 1][y + 1][0])
dfs(x + 1, y + 1, 0);
}
}
int main() {
//freopen("test.in", "r", stdin);
ios_base::sync_with_stdio(0);
cin >> n;
//cout << n << endl;
for(int i = 1; i <= 10; i++) {
cin >> s[i];
// cout << s[i] << endl;
s[i] = '#' + s[i];
}
//for(int i = 1; i <= 10; i++)
// cout << s[i] << endl;
dfs(10, 1, 0);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |