Submission #201087

#TimeUsernameProblemLanguageResultExecution timeMemory
201087SamAndJetpack (COCI16_jetpack)C++17
80 / 80
25 ms7920 KiB
#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)

jetpack.cpp: In function 'int main()':
jetpack.cpp:81:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", ans.size());
                    ~~~~~~~~~~^
jetpack.cpp:82:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ans.size(); ++i)
                     ~~^~~~~~~~~~~~
jetpack.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
jetpack.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...