# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201087 | SamAnd | Jetpack (COCI16_jetpack) | C++17 | 25 ms | 7920 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;
#define m_p make_pair
const int N = 100005;
int m;
char a[12][N];
bool c[12][N];
int p[12][N];
int main()
{
scanf("%d", &m);
for (int i = 0; i < 10; ++i)
{
scanf(" %s", a[i]);
}
c[9][0] = true;
for (int j = 0; j < m - 1; ++j)
{
for (int i = 0; i < 10; ++i)
{
if (!c[i][j])
continue;
if (i == 9)
{
if (a[i][j + 1] == '.')
{
c[i][j + 1] = true;
p[i][j + 1] = i;
}
}
if (i == 0)
{
if (a[i][j + 1] == '.')
{
c[i][j + 1] = true;
p[i][j + 1] = i;
}
}
if (i + 1 < 10)
{
if (a[i + 1][j + 1] == '.')
{
c[i + 1][j + 1] = true;
p[i + 1][j + 1] = i;
}
}
if (i - 1 >= 0)
{
if (a[i - 1][j + 1] == '.')
{
c[i - 1][j + 1] = true;
p[i - 1][j + 1] = i;
}
}
}
}
vector<pair<int, int> > ans;
int j = m - 1;
for (int i = 0; i < 10; ++i)
{
if (c[i][j])
{
while (1)
{
if (j == 0)
break;
if (p[i][j] > i || (p[i][j] == i && i == 0))
{
ans.push_back(m_p(j - 1, 1));
}
i = p[i][j];
--j;
}
break;
}
}
reverse(ans.begin(), ans.end());
printf("%d\n", ans.size());
for (int i = 0; i < ans.size(); ++i)
{
printf("%d %d\n", ans[i].first, ans[i].second);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |