AIregister @ 2024-10-13 14:17:14
#include <bits/stdc++.h>
using namespace std;
struct k {
long long w, l;
};
k a[10000001];
k b[10000001];
long long cnt1 = 1;
long long cnt2 = 1;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
char c;
while (1) {
cin >> c;
if (c == 'E') {
break;
}
if (c == 'W') {
a[cnt1].w++;
b[cnt2].w++;
}
if (c == 'L') {
a[cnt1].l++;
b[cnt2].l++;
}
if ((a[cnt1].l>=11||a[cnt1].w>=11)&&abs(a[cnt1].w-a[cnt1].l)>=2) {
cnt1++;
}
if ((b[cnt2].w >=21|| b[cnt2].l == 21)&&abs(b[cnt2].w-b[cnt2].l)>=2) {
cnt2++;
}
}
for (int i = 1; i <= cnt1; i++) {
cout << a[i].w << ":" << a[i].l;
cout << endl;
}
cout << endl;
for (int i = 1; i <= cnt2; i++) {
cout << b[i].w << ":" << b[i].l;
cout << endl;
}
return 0;
}
by AIregister @ 2024-10-13 14:19:19
wa on #2 #3
by 蒋辰逸 @ 2024-10-15 10:50:52
line 31 把 == 改成 >= 就过了。
#include <bits/stdc++.h>
using namespace std;
struct k {
long long w, l;
};
k a[10000001];
k b[10000001];
long long cnt1 = 1;
long long cnt2 = 1;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
char c;
while (1) {
cin >> c;
if (c == 'E') {
break;
}
if (c == 'W') {
a[cnt1].w++;
b[cnt2].w++;
}
if (c == 'L') {
a[cnt1].l++;
b[cnt2].l++;
}
if ((a[cnt1].l>=11||a[cnt1].w>=11)&&abs(a[cnt1].w-a[cnt1].l)>=2) {
cnt1++;
}
if ((b[cnt2].w >=21|| b[cnt2].l == 21)&&abs(b[cnt2].w-b[cnt2].l)>=2) {
cnt2++;
}
}
for (int i = 1; i <= cnt1; i++) {
cout << a[i].w << ":" << a[i].l;
cout << endl;
}
cout << endl;
for (int i = 1; i <= cnt2; i++) {
cout << b[i].w << ":" << b[i].l;
cout << endl;
}
return 0;
}
记得关
by 蒋辰逸 @ 2024-10-15 10:51:54
完了,4,5又WA了,先别关。
by 蒋辰逸 @ 2024-10-15 10:53:19
#include <bits/stdc++.h>
using namespace std;
struct k {
long long w, l;
};
k a[10000001];
k b[10000001];
long long cnt1 = 1;
long long cnt2 = 1;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
char c;
while (1) {
cin >> c;
if (c == 'E') {
break;
}
if (c == 'W') {
a[cnt1].w++;
b[cnt2].w++;
}
if (c == 'L') {
a[cnt1].l++;
b[cnt2].l++;
}
if ((a[cnt1].l>=11||a[cnt1].w>=11)&&abs(a[cnt1].w-a[cnt1].l)>=2) {
cnt1++;
}
if ((b[cnt2].w >=21|| b[cnt2].l >= 21)&&abs(b[cnt2].w-b[cnt2].l)>=2) {
cnt2++;
}
}
for (int i = 1; i <= cnt1; i++) {
cout << a[i].w << ":" << a[i].l;
cout << endl;
}
cout << endl;
for (int i = 1; i <= cnt2; i++) {
cout << b[i].w << ":" << b[i].l;
cout << endl;
}
return 0;
}
这下应该能过了,刚刚出了个玄学错。
by guoyanwei120223 @ 2024-10-19 16:12:49
@AIregister ```cpp
using namespace std; char wl[25*2501]; int main() { char a; int w=0,l=0; for(int i=0;a!='E';i++) { cin>>a; wl[i]=a; } for(int i=0;;i++) { if(wl[i]=='W') w++; if(wl[i]=='L') l++; if(max(w,l)>=11&&abs(w-l)>=2) { cout<<w<<":"<<l<<endl; w=0; l=0; } if(wl[i]=='E') { cout<<w<<":"<<l<<endl; cout<<endl; break; } } w=0,l=0; for(int i=0;;i++) { if(wl[i]=='W') w++; if(wl[i]=='L') l++; if(max(w,l)>=21&&abs(w-l)>=2) { cout<<w<<":"<<l<<endl; w=0; l=0; } if(wl[i]=='E') { cout<<w<<":"<<l<<endl; break; } }
}