#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
void kout(){ cerr << endl; }
template<class T1, class ...T2> void kout(T1 a, T2 ...e) { cerr << a << ' ', kout(e...); }
#else
#define DE(...) 0
#define deubg(...) 0
#endif
const int MAX_N = 111, wid1 = 4;
const ll inf = 1e18 + 10;
ll K;
char w[MAX_N][MAX_N];
ll way[MAX_N][MAX_N][2];
void add(ll &v, ll val) {
v = min(inf, v + val);
}
ll check1() {
memset(way, 0, sizeof(way));
way[1][1][0] = 1;
for (int i = 1;i <= wid1;++i)
for (int j = 1;j <= wid1;++j) {
ll sum = way[i][j][0] + way[i][j][1];
if (sum > K) return false;
if (w[i][j] == 'X') {
add(way[i+1][j][0], sum);
add(way[i][j+1][1], sum);
}
if (w[i][j] == 'r')
add(way[i][j+1][1], sum);
if (w[i][j] == 'd')
add(way[i+1][j][0], sum);
if (w[i][j] == '.') {
add(way[i+1][j][0], way[i][j][0]);
add(way[i][j+1][1], way[i][j][1]);
}
}
//DE(way[wid1][wid1][0] + way[wid1][wid1][1], K);
return way[wid1][wid1][0] + way[wid1][wid1][1];
}
bool dfs(int x, int y) {
if (x == wid1 && y == wid1)
return w[x][y] = '.', check1();
if (y > wid1)
return dfs(x+1, 1);
for (char s : {'r', 'd', 'X', '.'}) {
if (x == 1 && y == 1 && s == '.') continue;
if (y == wid1 && s == 'r') continue;
if (x == wid1 && s == 'd') continue;
w[x][y] = s;
if (dfs(x, y+1))
return true;
}
return false;
}
void subtask1() {
assert(dfs(0,0));
cout << wid1 << ' ' << wid1 << '\n';
for (int i = 1;i <= wid1;++i)
cout << w[i]+1 << '\n';
}
void subtask2() {
}
void logone(ll K) {
if (K == 2) {
cout << "2 2\nxd\nr.\n";
return;
}
int lev = __lg(--K);
int n = lev + 2;
for (int i = 1;i <= n;++i)
for (int j = 1;j <= n;++j)
w[i][j] = '.';
for (int i = 1;i <= n;++i)
w[i][n] = 'd', w[n][i] = 'r';
w[1][1] = 'r';
w[n][n] = '.';
for (int i = 2;i < n;++i) {
w[i][i] = 'X';
w[i][i+1] = 'd';
w[i+1][i] = 'r';
}
for (int i = 2, v = 1<<lev;i < n;++i, v>>=1) {
if (K & v) w[1][i] = 'X';
else w[1][i] = 'r';
}
if (K&1) w[1][1] = 'X';
cout << n << ' ' << n << '\n';
for (int i = 1;i <= n;++i)
cout << w[i]+1 << '\n';
DE(check1());
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> K;
logone(K);
}
Compilation message
costinland.cpp: In function 'void logone(ll)':
costinland.cpp:12:17: warning: statement has no effect [-Wunused-value]
12 | #define DE(...) 0
| ^
costinland.cpp:101:2: note: in expansion of macro 'DE'
101 | DE(check1());
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct! Your size: 3 |
2 |
Correct |
1 ms |
204 KB |
Correct! Your size: 3 |
3 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
4 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
5 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
6 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
7 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
8 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
9 |
Partially correct |
1 ms |
204 KB |
Partially Correct! Your size: 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
The matrix does not generate the required number of Costins |
2 |
Halted |
0 ms |
0 KB |
- |