社区讨论
建议升黄
P8964梦幻 | Reopening of Dream参与者 10已保存回复 9
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 9 条
- 当前快照
- 1 份
- 快照标识符
- @m2cqn1lz
- 此快照首次捕获于
- 2024/10/17 11:25 去年
- 此快照最后确认于
- 2025/11/04 17:01 4 个月前
这道题目牵涉到了字符串拼接+模拟,很容易RE,并且变量名很容易弄混,比如说如果当前字符串的长度<=那么就会截不到,最后会输出
CPPterminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 30) > this->size() (which is 13)
然而这道题目,我写的也是非常的复杂,代码如下
由于本人热爱篮球,喜欢老大,所以变量名请见谅
CPP#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
string a[N];
int tmp[N];
signed main()
{
int t,n,m;
cin>>t;
cin>>n>>m;
for(int i=1;i<=m;i++)cin>>a[i];
for(int i=1;i<=n;i++)
{
tmp[1]=0;
tmp[2]=0;
tmp[3]=0;
for(int j=1;j<=m;j++)
{
string res=a[j];
string man_1="freopen(\""+res+".in\",\"r\",stdin);";
string man_2="freopen(\""+res+".out\",\"w\",stdout);";
string man_3,man_4;
cin>>man_3>>man_4;
string man_sub_1,man_sub1_1,man_sub_2,man_sub1_2;
if(man_3.size()>12)
{
man_sub_1=man_3.substr(0,10);
man_sub1_1=man_3.substr(man_3.size()-2,2);
}
if(man_4.size()>12)
{
man_sub_2=man_4.substr(0,10);
man_sub1_2=man_4.substr(man_4.size()-2,2);
}
if(man_1==man_3&&man_2==man_4)
{
tmp[1]++;
}
else if((man_sub_1=="//freopen("&&man_sub1_1==");")||(man_sub_2=="//freopen("&&man_sub1_2==");"))
{
tmp[2]++;
}
else
{
tmp[3]++;
}
}
if(tmp[1]==m)cout<<"PION2202 RP++.\n";
else if(tmp[2]>0)cout<<"Wrong file operation takes you to your ancestors along with your 3 years' efforts on OI.\n";
else cout<<"Good luck and have fun.\n";
}
return 0;
}
回复
共 9 条回复,欢迎继续交流。
正在加载回复...