abc301_C 复盘1
dzy1004xsxdg · · 个人记录
第一次:
WA了第一个点
源代码:
#include<bits/stdc++.h>
using namespace std;
char s[200010],t[200010];
int main(){
int n1=0,n2=0;
int y1=0,y2=0;
int other_w1=0,other_w2=0;
int a;
cin>>a;
for(int i=0;i<a;i++){
cin>>s[i];
if(s[i]=='@'){
y1+=1;
}
else if(s[i]=='a'||s[i]=='t'||s[i]=='c'||s[i]=='o'||s[i]=='d'||s[i]=='e'||s[i]=='r'){
n1+=1;
}
else if(s[i]!='a'&&s[i]!='t'&&s[i]!='c'&&s[i]!='o'&&s[i]!='d'&&s[i]!='e'&&s[i]!='r'){
other_w1+=1;
}
}
for(int i=0;i<a;i++){
cin>>t[i];
if(t[i]=='@'){
y2+=1;
}
else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
n2+=1;
}
else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
other_w2+=1;
}
}
if(s==t){
cout<<"Yes";
return 0;
}
if(other_w1!=other_w2){
cout<<"No";
return 0;
}
if(n1!=n2&&other_w1==other_w2){
if(n1>n2){
if(y2>=n1-n2&&y1==y2-n1+n2){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
if(n1<n2){
if(y1>=n2-n1&&y2==y1-n2+n1){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
}
return 0;
}
认为是输入的问题,看了一下题解(by @FinderHT) 改了一下输入
char s[200010],t[200010];
string a;
cin>>a;
int l=a.size();
for(int i=0;i<l;i++){
s[i]=a[i];
}
for(int i=0;i<l;i++){
cin>>t[i];
}
第二次:
仍然WA=>#1
源代码
#include<bits/stdc++.h>
using namespace std;
char s[200010],t[200010];
int main(){
int n1=0,n2=0;
int y1=0,y2=0;
int other_w1=0,other_w2=0;
string a;
cin>>a;
int l=a.size();
for(int i=0;i<l;i++){
s[i]=a[i];
if(s[i]=='@'){
y1+=1;
}
else if(s[i]=='a'||s[i]=='t'||s[i]=='c'||s[i]=='o'||s[i]=='d'||s[i]=='e'||s[i]=='r'){
n1+=1;
}
else if(s[i]!='a'&&s[i]!='t'&&s[i]!='c'&&s[i]!='o'&&s[i]!='d'&&s[i]!='e'&&s[i]!='r'){
other_w1+=1;
}
}
for(int i=0;i<l;i++){
cin>>t[i];
if(t[i]=='@'){
y2+=1;
}
else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
n2+=1;
}
else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
other_w2+=1;
}
}
if(s==t){
cout<<"Yes";
return 0;
}
if(other_w1!=other_w2){
cout<<"No";
return 0;
}
if(n1!=n2&&other_w1==other_w2){
if(n1>n2){
if(y2>=n1-n2&&y1==y2-n1+n2){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
if(n1<n2){
if(y1>=n2-n1&&y2==y1-n2+n1){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
}
return 0;
}
自己测了一下样例,发现无论如何都是“No”
然后
if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
other_w2+=1;
}
}
c+v时忘记改成!=了!!!!
改完后发现“Yes”不会输出
第三次:
蒟蒻作死 在最后一个return 0后面加上了
cout<<"Yes";
Genshin谨慎地测了一下样例
过了
BUT
25=>WA了
源代码
#include<bits/stdc++.h>
using namespace std;
char s[200010],t[200010];
int main(){
int n1=0,n2=0;
int y1=0,y2=0;
int other_w1=0,other_w2=0;
string a;
cin>>a;
int l=a.size();
for(int i=0;i<l;i++){
s[i]=a[i];
if(s[i]=='@'){
y1+=1;
}
else if(s[i]=='a'||s[i]=='t'||s[i]=='c'||s[i]=='o'||s[i]=='d'||s[i]=='e'||s[i]=='r'){
n1+=1;
}
else if(s[i]!='a'&&s[i]!='t'&&s[i]!='c'&&s[i]!='o'&&s[i]!='d'&&s[i]!='e'&&s[i]!='r'){
other_w1+=1;
}
}
for(int i=0;i<l;i++){
cin>>t[i];
if(t[i]=='@'){
y2+=1;
}
else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
n2+=1;
}
else if(t[i]!='a'||t[i]!='t'||t[i]!='c'||t[i]!='o'||t[i]!='d'||t[i]!='e'||t[i]!='r'){
other_w2+=1;
}
}
if(s==t){
cout<<"Yes";
return 0;
}
if(other_w1!=other_w2){
cout<<"No";
return 0;
}
if(n1!=n2&&other_w1==other_w2){
if(n1>n2){
if(y2>=n1-n2&&y1==y2-n1+n2){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
if(n1<n2){
if(y1>=n2-n1&&y2==y1-n2+n1){
cout<<"Yes";
return 0;
}
else{
cout<<"No";
return 0;
}
}
}
cout<<"Yes";
return 0;
}
开始自己造数据 并与红名神犇@FinderHT 的题解代码结果对比
-
32位 结果相同
-
72位 结果相同
-
144位 结果。。。不同
犇:No 蒟蒻:Yes。。。。。。
@b@@@ffghijklmn@pq@s@uvwxyz@@@@@@@abc@bcd@fgihjkmln@pqrs@uvwyxz@tc@@@rabcab@@effhgjimklonqp@su@xvwyza@@o@er@bcab@d@fhgjimkl@npq@su@xwvy@z@oc@e@@bc abcd@fxhgjimkl@npq@su@xvwyza@@ode@@bcab@d@fhgjimkl@npq@su@xwvy@z@@o@e@@b@ab@@effghmjilkqonp@su@xvwyza@@o@er@bcab@d@fhgjimkl@npq@su@xwvy@z@oc@e@@bc这是我造的数据
蒟蒻已疯
底线