Submission #1234771

#TimeUsernameProblemLanguageResultExecution timeMemory
1234771SolikhaCostinland (info1cup19_costinland)C++20
20 / 100
0 ms328 KiB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ss second
#define ff first
#define pb push_back 
 
void solve(){

  auto check = [&](vector<vector<char>> &v) -> int{
    vector<vector<int>> sum(5, vector<int> (5));
    sum[0][0] = 1;
    int res = 0;
    for(int i = 0; i < 5; i ++){
      for(int j = 0; j < 5; j++){
        if(v[i][j] == 'X'){
          res += sum[i][j];
          sum[i][j + 1] += sum[i][j];
          sum[i + 1][j] += sum[i][j];
        }
      }
    }
    return res + 1;
  };

  int k; cin >> k;
    vector<vector<char>> v(5, vector<char> (5, '.'));
    vector<vector<int>> cnt(5, vector<int> (5));
    v[0][0] = 'X';
    cnt[0][1] = 1;
    cnt[1][0] = 1;
    for(int i = 0; i < 5; i ++){
      for(int j = 0; j < 5; j ++){
        if(i < 4 && j == 4) v[i][j] = 'd';
        if(i == 4 && j < 4) v[i][j] = 'r';
      }
    }

    int ans = 2;
    for(int i = 0; i < 4; i++){
      bool d = false;
      for(int j = 0; j < 4; j++){
        if(i == 0 && j == 0) continue;
        if(ans == k) v[i][j] = 'r';
        else{
          if(cnt[i][j] <= k - ans && !d){
            v[i][j] = 'X';
            ans += cnt[i][j];
            cnt[i][j + 1] += cnt[i][j];
            cnt[i + 1][j] += cnt[i][j];
          }else{
            v[i][j] = 'r';
            d = true;
          }
        }
      }
    }

  //cout << endl << k << endl;
  cout << "5 5" << endl;
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++) cout << v[i][j];
    cout << endl;
  }
}

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t = 1; //cin >> t;
  while(t--){
    solve();
    cout << endl;
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...