__Harry_Haiyun__ @ 2023-09-09 11:55:43
#include <bits/stdc++.h>
#define int long long
#define iostream() ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;
const int maxn = 1e6+7;
const int MAXN = maxn / 2;
signed main()
{
iostream();
int n,m,k,x,y;
cin >> n >> m >> k;
char c[n][m],l,d;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
c[i][j] = '.';
while (k--)
{
cin >> x >> y >> l >> d;
switch (d)
{
case 'L':
for (int i = 0; i < y; i++)
c[x][i] = l;
break;
case 'R':
for (int i = y; i < m; i++)
c[x][i] = l;
break;
case 'U':
for (int i = 0; i < x; i++)
c[i][y] = l;
break;
case 'D':
for (int i = x; i < n; i++)
c[i][y] = l;
break;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
cout << c[i][j] << ' ';
cout << '\n';
}
return 0;
}
by __Harry_Haiyun__ @ 2023-09-09 11:56:20
不好意思,代码贴错了:
#include <bits/stdc++.h>
#define int long long
#define iostream() ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;
const int maxn = 1e6+7;
const int MAXN = maxn / 2;
signed main()
{
iostream();
string s;
cin >> s;
stack<char>st;
for (int i = 0; i < s.length(); i++)
{
switch (s[i])
{
case '(':
st.push('(');
break;
case ')':
if (st.empty())
{
cout << '(';
break;
}
else
{
st.pop();
break;
}
}
}
if (st.top() == '(')
{
cout << s;
while (st.size())
{
cout << ')';
st.pop();
}
}
return 0;
}
by qtnu_acorgi @ 2023-09-14 15:48:29
栈执行完可能为空,空的情况下top()函数会RE。例:))