Submission #1005600

#TimeUsernameProblemLanguageResultExecution timeMemory
1005600otariusCostinland (info1cup19_costinland)C++17
100 / 100
1 ms460 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; ll n; char arr[50][50]; vector<vector<pii>> add = { {}, {{2, 0}}, {{2, 0}, {0, 2}}, {{2, 1}}, {{2, 0}, {2, 1}}, {{2, 0}, {2, 1}, {0, 2}} }; int dfs(int x, int y, int dir) { if (x > 4 || y > 4) return 1; if (arr[x][y] == 'X') return dfs(x + 1, y, 0) + dfs(x, y + 1, 1); if (dir == 0) return dfs(x + 1, y, 0); return dfs(x, y + 1, 1); } void go20() { for (int i = 0; i < (1 << 16); i++) { for (int j = 1; j <= 16; j++) { if ((i >> (j - 1)) % 2 == 1) { if (j % 4 == 0) arr[j / 4][4] = 'X'; else arr[j / 4 + 1][j % 4] = 'X'; } else { if (j % 4 == 0) arr[j / 4][4] = '.'; else arr[j / 4 + 1][j % 4] = '.'; } } if (arr[1][1] != 'X') continue; if (dfs(1, 1, 0) == n) { cout << "5 5\n"; for (int j = 1; j <= 5; j++) { for (int k = 1; k <= 5; k++) { if (j == 5 && k == 5) cout << '.'; else if (j == 5) cout << 'r'; else if (k == 5) cout << 'd'; else cout << arr[j][k]; } cout << '\n'; } return; } } } vector<int> get(ll x) { vector<int> ans; while (x) { ans.pb(x % 6); x /= 6; } return ans; } void go80() { for (int i = 1; i <= 49; i++) for (int j = 1; j <= 49; j++) arr[i][j] = '.'; for (int i = 1; i <= 48; i++) arr[i][49] = 'd'; for (int j = 1; j <= 48; j++) arr[49][j] = 'r'; vector<int> v = get(n); for (int i = 0; i < v.size() - 1; i++) { int pos = 2 * i + 1; arr[pos][pos] = 'X'; arr[pos][pos + 1] = 'X'; arr[pos + 1][pos] = 'X'; arr[pos + 1][pos + 1] = 'X'; arr[pos + 2][pos] = 'r'; arr[pos][pos + 2] = 'd'; arr[pos + 2][pos + 1] = 'r'; arr[pos + 1][pos + 2] = 'd'; for (pii j : add[v[i]]) arr[pos + j.ff][pos + j.sc] = 'X'; } int pos = 2 * (int)(v.size() - 1) + 1, vl = v.back(); if (vl == 2) { arr[pos][pos] = 'X'; } if (vl == 3) { arr[pos][pos] = 'X'; arr[pos + 1][pos] = 'X'; } if (vl == 4) { arr[pos][pos] = 'X'; arr[pos + 1][pos] = 'X'; arr[pos][pos + 1] = 'X'; } if (vl == 5) { arr[pos][pos] = 'X'; arr[pos + 1][pos] = 'X'; arr[pos][pos + 1] = 'X'; arr[pos][pos + 2] = 'X'; } cout << "49 49\n"; for (int i = 1; i <= 49; i++) { for (int j = 1; j <= 49; j++) { cout << arr[i][j]; } cout << '\n'; } } void solve() { cin >> n; if (n <= 19) go20(); else go80(); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }

Compilation message (stderr)

costinland.cpp: In function 'void go80()':
costinland.cpp:74:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |     for (int i = 0; i < v.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...