Submission #923105

# Submission time Handle Problem Language Result Execution time Memory
923105 2024-02-06T16:14:32 Z Ianis Costinland (info1cup19_costinland) C++17
0 / 100
9 ms 348 KB
#ifdef LOCAL
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <random>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#else
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#define cerr if (false) cerr 
#define endl '\n'
#endif

#define fi first
#define se second

#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()

#define lsb(x) (x & (-x))

#define bit(mask, i) (((mask) >> (i)) & 1)
#define popcount(x) __builtin_popcount(x)

#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

using namespace std;

template <typename T>
bool ckmax(T &a, T b) { return a < b ? a = b, true : false; }
template <typename T>
bool ckmin(T &a, T b) { return a > b ? a = b, true : false; }

#define int __int128_t

using pii = pair<int, int>;

int32_t n, m, k;
char a[55][55];
int dpd[55][55], dpr[55][55];

ostream &operator<<(ostream &out, int x) {
   string s;
   if (x == 0) {
      out << 0;
      return out;
   }
   while (x) {
      s.push_back((x % 10) + '0');
      x /= 10;
   }
   reverse(all(s));
   out << s;
   return out;
}

int calc() {
   dpd[0][1] = 1;
   for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
         if (a[i][j] == 'X') {
            dpd[i][j] = dpr[i][j] = dpd[i - 1][j] + dpr[i][j - 1];
         } else if (a[i][j] == 'r') {
            dpr[i][j] = dpd[i - 1][j] + dpr[i][j - 1];
            dpd[i][j] = 0;
         } else if (a[i][j] == 'd') {
            dpd[i][j] = dpd[i - 1][j] + dpr[i][j - 1];
            dpr[i][j] = 0;
         } else {
            dpd[i][j] = dpd[i - 1][j];
            dpr[i][j] = dpr[i][j - 1];
         }
      }
   }

   return dpd[n][m] + dpr[n][m];
}

void solve() {
   if (k <= 19)
      n = m = 5;
   else
      n = m = 49;

   for (int i = 1; i < n; i++) {
      for (int j = 1; j < m; j++)
         a[i][j] = '.';
   }

   for (int i = 1; i <= n; i++)
      a[i][m] = 'd';
   for (int j = 1; j <= m; j++)
      a[n][j] = 'r';
   a[n][m] = '.';

   int val = 1;

   for (int i = 1; i < n; i++) {
      for (int j = 1; j < m; j++) {
         a[i][j] = 'X';
         int v = calc();
         if (v > k) a[i][j] = '.';
         else val = v;
      }
   }

   for (int i = 1; i <= n; i++) {
      cout << (a[i] + 1) << endl;
   }
}

signed main() {
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   cin >> k;
   solve();

   return 0;
}

Compilation message

costinland.cpp: In function 'void solve()':
costinland.cpp:102:8: warning: variable 'val' set but not used [-Wunused-but-set-variable]
  102 |    int val = 1;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Expected integer, but "XX..d" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 348 KB Expected integer, but "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXd" found
2 Halted 0 ms 0 KB -