社区讨论
初一萌新刚学OI求条
P8289[省选联考 2022] 预处理器参与者 4已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mhj24jds
- 此快照首次捕获于
- 2025/11/03 19:28 4 个月前
- 此快照最后确认于
- 2025/11/03 19:28 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc _getchar_nolock
#define pc _putchar_nolock
#endif
#define int long long
// #define R register
#define rint register int
#define _ read<int>()
inline bool blank(const char x)
{
return !(x^9)||!(x^13)||!(x^10)||!(x^32);
}
template<class T>inline T read()
{
T r=0,f=1;char c=gc();
while(!isdigit(c))
{
if(c=='-') f=-1;
c=gc();
}
while(isdigit(c)) r=(r<<1)+(r<<3)+(c^48),c=gc();
return f*r;
}
inline void out(int x)
{
if(x<0) pc('-'),x=-x;
if(x<10) pc(x+'0');
else out(x/10),pc(x%10+'0');
}
const int N=110;
string ss[N][N],s;
int b[N];
map<string,string>mp;
inline void p(const string &x,string l[],int h)
{
b[h]=1;
for(char c:x)
{
if(c==' ') b[h]++;
else l[b[h]]+=c;
}
}
inline string z(const string &x)
{
string l="";
for(char c:x)
{
if((c>='A'&&c<='Z')||(c>='0'&&c<='9')||(c>='a'&&c<='z')) l+=c;
}
return l;
}
signed main()
{
rint n=_;
for(rint i=1;i<=n;i++)
{
cin>>ss[i][1];
if(ss[i][1][0]=='#')
{
cin>>ss[i][2];
getline(cin,ss[i][3]);
}
else
{
s="";
getline(cin,s);
p(s,ss[i],i);
}
}
for(rint i=1;i<=n;i++)
{
if(ss[i][1][0]=='#')
{
if(ss[i][1][1]=='d')
{
mp[z(ss[i][2])]=ss[i][3];
}
else
{
mp[z(ss[i][2])]="";
}
}
else
{
for(rint j=1;j<=b[i];j++)
{
if(mp[z(ss[i][j])]!="")
{
for(rint k=1;k<mp[z(ss[i][j])].size();k++)
{
pc(mp[z(ss[i][j])][k]);
}
for(rint k=0;k<ss[i][j].size();k++)
{
char c=ss[i][j][k];
if((c>='A'&&c<='Z')||(c>='0'&&c<='9')||(c>='a'&&c<='z'));
else pc(c);
}
}
else
{
cout<<ss[i][j];
}
pc(' ');
}
}
pc('\n');
}
return 0;
}
我知道我写的不是正解但是样例2就错了求条
回复
共 5 条回复,欢迎继续交流。
正在加载回复...