Submission #1103003

# Submission time Handle Problem Language Result Execution time Memory
1103003 2024-10-19T10:44:48 Z bvv23 Jetpack (COCI16_jetpack) C++17
64 / 80
27 ms 4272 KB
// Ahmadov orz
/// successful failure
#include <bits/stdc++.h>
/// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
/// using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define drop(x) cout<<x<<endl;return
// template <class T>
// using isTree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/// sometimes you gotta think simple
struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};
const int N = 10 + 7;
const int M = 5e4 + 7;
char g[N][M];
vector <int> path, path2;
bool dfs(int i, int j, int n) 
{
    if (i < 0 || i > n - 1 || g[i][j] == 'X') {
        return 0;
    }
    if (j == n - 1) {
        return 1;       // cata bilir, ok
    }
    g[i][j] = 'X';
    if (dfs(min(9LL,i + 1), j + 1, n) == 1) {
        return 1;
    }
    if (dfs(max(0LL,i - 1), j + 1, n) == 1) {       // i-1 yuxari cixmaq
        path.pb(j);
        return 1;
    }
    return 0;
}
void failure()
{
    int n;
    cin >> n;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < n; j++) {
            cin >> g[i][j];
        }
    }
    bool menasiz = dfs(9, 0, n);
    reverse(all(path));
    cout << path.size() << endl;
    for (int i = 0; i < path.size(); i++) {
        cout << path[i] << " " << 1 << endl;
    }
} 
signed main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(NULL);                
    cout.tie(NULL);
    int tt = 1;
    //cin >> tt;
    while (tt--)
    {
        failure();
    }
}

Compilation message

jetpack.cpp: In function 'void failure()':
jetpack.cpp:59:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < path.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
jetpack.cpp:56:10: warning: unused variable 'menasiz' [-Wunused-variable]
   56 |     bool menasiz = dfs(9, 0, n);
      |          ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 13 ms 1876 KB Output is correct
8 Correct 27 ms 3952 KB Output is correct
9 Incorrect 11 ms 4172 KB Crashed with an obstacle
10 Incorrect 13 ms 4272 KB Crashed with an obstacle