Submission #171670

#TimeUsernameProblemLanguageResultExecution timeMemory
171670Tuk1352Jetpack (COCI16_jetpack)C++11
80 / 80
124 ms10500 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char C[10][n]; int D[10][n+1], P[10][n+1], I, Y=n-1; for (int i = 0; i < 10; i++) { for (int y = 0; y < n; y++) { cin >> C[i][y]; P[i][y] = 0; } } for (int i = 0; i < 10; i++) { D[i][0] = 0; } D[9][0] = 1; for (int y = 1; y < n; y++) { for (int i = 0; i < 10; i++) { D[i][y] = 0; if (C[i][y] != 'X') { if (i == 9) { if (D[i][y-1] == 1) { D[i][y] = 1; } else if (D[i-1][y-1] == 1) { D[i][y] = 1; P[i][y] = -1; } } else if (i == 0) { if (D[i][y-1] == 1) { D[i][y] = 1; } else if (D[i+1][y-1] == 1) { D[i][y] = 1; P[i][y] = 1; } } else { if (D[i-1][y-1] == 1) { P[i][y] = -1; D[i][y] = 1; } else if (D[i+1][y-1] == 1) { P[i][y] = 1; D[i][y] = 1; } } } } } for (int i = 0; i < 9; i++) { if (D[i][n-1] == 1) { I = i; } } vector <pair<int,int>> V; int k = 0; while (Y != -1) { if (P[I][Y] == 1 || (P[I][Y] == 0 && I == 0)) { k++; } else if (k != 0) { V.push_back({Y,k}); k = 0; } I += P[I][Y]; Y--; } cout << V.size() << "\n"; for (int i = V.size()-1; i >= 0; i--) { cout << V[i].first << " " << V[i].second << "\n"; } return 0; }

Compilation message (stderr)

jetpack.cpp: In function 'int main()':
jetpack.cpp:82:43: warning: 'I' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (P[I][Y] == 1 || (P[I][Y] == 0 && I == 0))
                             ~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...