답안 #1005319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005319 2024-06-22T10:20:14 Z otarius Costinland (info1cup19_costinland) C++17
20 / 100
1 ms 348 KB
#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;
    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';
        }
    } 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct! Your size: 5
2 Correct 0 ms 348 KB Correct! Your size: 5
3 Correct 0 ms 348 KB Correct! Your size: 5
4 Correct 0 ms 348 KB Correct! Your size: 5
5 Correct 0 ms 348 KB Correct! Your size: 5
6 Correct 0 ms 348 KB Correct! Your size: 5
7 Correct 1 ms 348 KB Correct! Your size: 5
8 Correct 0 ms 348 KB Correct! Your size: 5
9 Correct 0 ms 348 KB Correct! Your size: 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB The output does not fit the requirements
2 Halted 0 ms 0 KB -