社区讨论
玄关求条(8*RE + 2*WA)
P1058[NOIP 2008 普及组] 立体图参与者 1已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mhjlh0lo
- 此快照首次捕获于
- 2025/11/04 04:30 4 个月前
- 此快照最后确认于
- 2025/11/04 04:30 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
char c[1005][1005];
int h[55][55];
int k = 0, l = 0;
int n, m;
int calc_eh(int x)
{
return 3 * x + 1;
}
void calc_kl()
{
k = 0;
for (int i = n; i >= 1; i--)
{
int row_height = 2 * (n - i);
for (int j = 1; j <= m; j++)
{
k = max(k, row_height + calc_eh(h[i][j]));
}
}
l = 4 * m + 2;
}
void draw(int x, int y)
{
c[x][y] = '+';
c[x - 3][y] = '+';
c[x][y + 4] = '+';
c[x - 3][y + 4] = '+';
c[x - 2][y + 6] = '+';
c[x - 5][y + 6] = '+';
c[x - 5][y + 2] = '+';
c[x - 1][y] = '|';
c[x - 2][y] = '|';
c[x - 1][y + 4] = '|';
c[x - 2][y + 4] = '|';
c[x - 3][y + 6] = '|';
c[x - 4][y + 6] = '|';
c[x][y + 1] = '-';
c[x][y + 2] = '-';
c[x][y + 3] = '-';
c[x - 3][y + 1] = '-';
c[x - 3][y + 2] = '-';
c[x - 3][y + 3] = '-';
c[x - 5][y + 3] = '-';
c[x - 5][y + 4] = '-';
c[x - 5][y + 5] = '-';
c[x - 1][y + 5] = '/';
c[x - 4][y + 5] = '/';
c[x - 4][y + 1] = '/';
for (int i = x - 2; i <= x - 1; i++)
{
for (int j = y + 1; j <= y + 3; j++)
{
c[i][j] = ' ';
}
}
c[x - 4][y + 2] = ' ';
c[x - 4][y + 3] = ' ';
c[x - 4][y + 4] = ' ';
c[x - 2][y + 5] = ' ';
c[x - 3][y + 5] = ' ';
}
pair<int, int> calc_ldis(int i, int j)
{
return {(n - i) * 2 + 4 * (j - 1), 4 + 2 * j};
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> h[i][j];
}
}
cerr << 111 << endl;
calc_kl();
cerr << 111 << endl;
for (int i = 1; i <= k; i++)
{
for (int j = 1; j <= l; j++)
{
c[i][j] = '.';
}
}
cerr << 111 << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
int ht = h[i][j];
cerr << 111 << endl;
pair<int, int> lf = calc_ldis(i, j);
cerr << 111 << endl;
int ii = lf.first + 1;
int jj = lf.second;
for (int k = 1; k <= ht; k++, ii -= 3)
{
draw(ii, jj);
}
}
}
cerr << 111 << endl;
for (int i = 1; i <= k; i++)
{
for (int j = 1; j <= l; j++)
{
cout << c[i][j];
}
cout << endl;
}
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...