이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[61][62];
// dir = 0, down
// dir = 1, right
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;
}
}
}
void go80() {
ll t = n; int cnt = -1;
while (t) { cnt++; t >>= 1; }
cout << cnt + 1 << ' ' << cnt + 2 << '\n';
for (int i = 1; i <= cnt + 1; i++)
for (int j = 1; j <= cnt + 2; j++) arr[i][j] = '.';
for (int i = 1; i <= cnt + 1; i++) arr[i][cnt + 2] = 'd';
for (int j = 1; j <= cnt + 2; j++) arr[cnt + 1][j] = 'r';
for (int i = 1, k = cnt + 1; k > 1; i++, k--)
for (int j = 2; j <= k; j++) arr[i][j] = 'X';
bool is_last = 1; ll now = n;
if (now & 1) is_last = 0; now >>= 1;
for (int i = cnt; i >= 1; i--) {
if (now & 1) {
if (is_last) {
is_last = 0; arr[i][1] = 'r';
} else arr[i][1] = 'X';
} now >>= 1;
} for (int i = 1; i <= cnt + 1; i++) {
for (int j = 1; j <= cnt + 2; 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;
}
컴파일 시 표준 에러 (stderr) 메시지
costinland.cpp: In function 'void go80()':
costinland.cpp:71:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
71 | if (now & 1) is_last = 0; now >>= 1;
| ^~
costinland.cpp:71:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
71 | if (now & 1) is_last = 0; now >>= 1;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |