Submission #753524

#TimeUsernameProblemLanguageResultExecution timeMemory
753524ksu2009enCostinland (info1cup19_costinland)C++17
20 / 100
43 ms216 KiB
#include <iostream> #include <vector> #include <string> #include <math.h> #include <cmath> #include <iomanip> #include <cstdio> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <stack> #include <deque> #include <bitset> #include <cstring> #include <unordered_map> using namespace std; typedef long long ll; void print(vector<vector<char>>a){ cout << a.size() << ' ' << a[0].size() << endl; for(auto i : a){ for(auto j: i) cout << j; cout << endl; } } void print(vector<vector<ll>>a){ for(auto i : a){ for(auto j: i) cout << j << ' '; cout << endl; } } void move_right(ll i, ll j, ll val, vector<vector<ll>> &dp, vector<vector<char>> &a){ for(int j2 = j + 1; j2 < dp[0].size(); j2++){ if(a[i][j2] != '.' || (i == dp.size() - 1 && j2 == dp[0].size() - 1)){ dp[i][j2] += val; break; } } } void move_down(ll i, ll j, ll val, vector<vector<ll>> &dp, vector<vector<char>> &a){ for(int i2 = i + 1; i2 < dp.size(); i2++){ if(a[i2][j] != '.' || (i2 == dp.size() - 1 && j == dp[0].size() - 1)){ dp[i2][j] += val; break; } } } ll cnt(vector<vector<char>> a){ vector<vector<ll>>dp(a.size(), vector<ll>(a[0].size())); dp[0][0] = 1; for(int i = 0; i < a.size(); i++){ for(int j = 0; j < a[0].size(); j++){ if(i == a.size() - 1 && j == a[0].size() - 1) break; if(a[i][j] == 'X' || a[i][j] == 'r'){ move_right(i, j, dp[i][j], dp, a); } if(a[i][j] == 'X' || a[i][j] == 'd'){ move_down(i, j, dp[i][j], dp, a); } dp[i][j] = 0; //cout << i << ' ' << j << endl; //print(dp); } } return dp[a.size() - 1][a[0].size() - 1]; } int main(){ ll t = 1; while(t--){ ll a; cin >> a; if(a == 1){ vector<vector<char>> d = {{'r', 'd'}, {'r', '.'}}; print(d); break; } ll sz = 16; for(int mask = 0; mask < (1 << sz); mask++){ vector<vector<char>>d(5, vector<char>(5)); ll ind = 0; for(int i = 0; i < 5; i++){ if(i == 4){ for(int j = 0; j < 5; j++){ d[i][j] = 'r'; } d[4][4] = '.'; break; } for(int j = 0; j < 5; j++){ if(j == 4){ d[i][j] = 'd'; continue; } if((mask >> ind) % 2 != 0) d[i][j] = 'X'; else d[i][j] = '.'; ind++; } } //print(d); if(d[0][0] == '.') continue; if(cnt(d) == a){ print(d); break; } } } return 0; }

Compilation message (stderr)

costinland.cpp: In function 'void move_right(ll, ll, ll, std::vector<std::vector<long long int> >&, std::vector<std::vector<char> >&)':
costinland.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int j2 = j + 1; j2 < dp[0].size(); j2++){
      |                         ~~~^~~~~~~~~~~~~~
costinland.cpp:40:34: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(a[i][j2] != '.' || (i == dp.size() - 1 && j2 == dp[0].size() - 1)){
      |                                ~~^~~~~~~~~~~~~~~~
costinland.cpp:40:57: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(a[i][j2] != '.' || (i == dp.size() - 1 && j2 == dp[0].size() - 1)){
      |                                                      ~~~^~~~~~~~~~~~~~~~~~~
costinland.cpp: In function 'void move_down(ll, ll, ll, std::vector<std::vector<long long int> >&, std::vector<std::vector<char> >&)':
costinland.cpp:47:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i2 = i + 1; i2 < dp.size(); i2++){
      |                         ~~~^~~~~~~~~~~
costinland.cpp:48:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(a[i2][j] != '.' || (i2 == dp.size() - 1 && j == dp[0].size() - 1)){
      |                                ~~~^~~~~~~~~~~~~~~~
costinland.cpp:48:57: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(a[i2][j] != '.' || (i2 == dp.size() - 1 && j == dp[0].size() - 1)){
      |                                                       ~~^~~~~~~~~~~~~~~~~~~
costinland.cpp: In function 'll cnt(std::vector<std::vector<char> >)':
costinland.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i = 0; i < a.size(); i++){
      |                    ~~^~~~~~~~~~
costinland.cpp:62:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j = 0; j < a[0].size(); j++){
      |                        ~~^~~~~~~~~~~~~
costinland.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if(i == a.size() - 1 && j == a[0].size() - 1)
      |                ~~^~~~~~~~~~~~~~~
costinland.cpp:63:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if(i == a.size() - 1 && j == a[0].size() - 1)
      |                                     ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...