#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
vi rems;
int get_log(ll k, bool type){
int cnt = 0;
while(k > 0){
cnt++;
if(type)
rems.pb(k % 6);
k /= (type ? 6 : 2);
}
return cnt;
}
void under_19(ll k){
if(k == 19){
cout << "5 5\nXXXXd\nXXXXd\ndrrrd\nXXXXd\nrrrr.\n";
return;
}
int n = get_log(k, 0);
vector<vector<char>> a(n+1, vector<char>(n+1, '.'));
for(int i = 0; i < n-1; i++){
a[i][i] = 'X';
a[i+1][i] = ((1LL << i) & k ? 'X' : 'r');
a[i][i+1] = 'd';
}
for(int i = 0; i <= n; i++){
a[n][i] = 'r';
a[i][n] = 'd';
}
a[n][n] = '.';
cout << n+1 << ' ' << n+1 << '\n';
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++)
cout << a[i][j];
cout << '\n';
}
}
void solve(){
rems.clear();
ll k;
cin >> k;
if(k <= 19){
under_19(k);
return;
}
int n = get_log(k, 1) * 2, sz = 49;
vector<vector<char>> a(sz, vector<char>(sz, '.'));
for(int i = 0; i < n-2; i += 2){
a[i][i] = a[i+1][i] = a[i][i+1] = a[i+1][i+1] = 'X';
a[i][i+2] = a[i+1][i+2] = 'd';
a[i+2][i] = a[i+2][i+1] = 'r';
}
for(int i = 0; i < rems.size()-1; i++){
int ind = i*2;
if(rems[i] == 0)
continue;
if(rems[i] == 1){
a[ind+2][ind] = 'X';
continue;
}
if(rems[i] == 2){
a[ind][ind+2] = 'X';
a[ind+2][ind] = 'X';
continue;
}
a[ind+2][ind] = 'X';
a[ind][ind+2] = 'X';
int down = (rems[i]-2) / 2;
int right = (rems[i]-2) - down;
for(int j = 0; j < down; j++){
a[ind+3+j][ind] = 'X';
a[ind+3+j][ind+1] = 'd';
}
for(int j = 0; j < right; j++){
a[ind][ind+3+j] = 'X';
a[ind+1][ind+3+j] = 'r';
}
}
for(int i = 0; i < sz; i++){
a[sz-1][i] = 'r';
a[i][sz-1] = 'd';
}
a[sz-1][sz-1] = '.';
if(rems.back() == 2){
a[n-2][n-2] = 'X';
} else if(rems.back() == 3){
a[n-2][n-2] = a[n-1][n-2] = 'X';
} else if(rems.back() == 4){
a[n-2][n-2] = a[n-1][n-2] = a[n-2][n-1] = 'X';
} else if(rems.back() == 5){
a[n-2][n-2] = a[n-1][n-2] = a[n][n-2] = a[n-2][n-1] = 'X';
}
cout << sz << ' ' << sz << '\n';
for(int i = 0; i < sz; i++){
for(int j = 0; j < sz; j++)
cout << a[i][j];
cout << '\n';
}
}
int main(){
//freopen("input.txt", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
///cin >> t;
while(t--){
solve();
}
}
Compilation message
costinland.cpp: In function 'void solve()':
costinland.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for(int i = 0; i < rems.size()-1; i++){
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Correct! Your size: 3 |
2 |
Correct |
1 ms |
212 KB |
Correct! Your size: 4 |
3 |
Correct |
1 ms |
212 KB |
Correct! Your size: 4 |
4 |
Correct |
1 ms |
212 KB |
Correct! Your size: 4 |
5 |
Correct |
1 ms |
212 KB |
Correct! Your size: 4 |
6 |
Correct |
1 ms |
212 KB |
Correct! Your size: 5 |
7 |
Correct |
1 ms |
212 KB |
Correct! Your size: 5 |
8 |
Correct |
1 ms |
212 KB |
Correct! Your size: 5 |
9 |
Correct |
0 ms |
212 KB |
Correct! Your size: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
2 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
3 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
4 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
5 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
6 |
Correct |
1 ms |
312 KB |
Correct! Your size: 49 |
7 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |
8 |
Correct |
1 ms |
212 KB |
Correct! Your size: 49 |