結果
問題 |
No.2339 Factorial Paths
|
ユーザー |
![]() |
提出日時 | 2023-06-03 02:25:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,182 bytes |
コンパイル時間 | 4,047 ms |
コンパイル使用メモリ | 257,612 KB |
最終ジャッジ日時 | 2025-02-13 21:59:28 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; void divide(int n, vector<pair<int,int>> &g){ if (n == 1) return; if (n == 3){ g.push_back(pair(3, 3)); return; } int t = n / 2; int s = n - t; g.push_back(pair(t+1, s+1)); divide(t, g); divide(s, g); } int main(){ int n; cin >> n; if (n == 1){ cout << 1 << " " << 1 << endl; cout << "." << endl; return 0; } vector<pair<int,int>> g; int h = 0, w = 0; divide(n, g); for (int i=0; i<(int)g.size(); i++){ if (g[i].first < g[i].second){ swap(g[i].first, g[i].second); } h += g[i].first; w += g[i].second; //cout << g[i].first << " " << g[i].second << endl; } h -= (int)g.size() - 1; vector<vector<char>> s(h, vector<char>(w, '#')); int ph = 0; int pw = 0; for (int i=0; i<(int)g.size(); i++){ for (int x=ph; x<ph+g[i].first; x++){ for (int y=pw; y<pw+g[i].second; y++){ s[x][y] = '.'; } } ph += g[i].first - 1; pw += g[i].second; } cout << h << " " << w << endl; //return 0; for (int i=0; i<h; i++){ for (int j=0; j<w; j++){ cout << s[i][j]; } cout << endl; } }