为什么结果不一样
  • 板块灌水区
  • 楼主huboxuan
  • 当前回复7
  • 已保存回复7
  • 发布时间2024/8/19 10:19
  • 上次更新2024/8/19 11:53:23
查看原帖
为什么结果不一样
1015155
huboxuan楼主2024/8/19 10:19

题目传送门

#include <bits/stdc++.h>
using namespace std;
char tmp[1];
int a[1001],sai_zhi[2]={11,21},cnt;
int main(){
    while(1){
        cin>>tmp[0];
        if(tmp[0]=='E') break;
        else if(tmp[0]=='W') a[cnt++]=1;
        else a[cnt++]=0;
    }
    for(int i=0;i<2;i++){
        int win=0,lose=0;
        for(int j=0;j<cnt;j++){
            win+=a[j];
            lose+=1-a[j];
            if(max(win,lose)>=sai_zhi[i]&&abs(win-lose)>=2){
                printf("%d:%d\n",win,lose);
                win=lose=0;
            }    
        }
        printf("%d:%d\n\n",win,lose);
    }
    return 0;
}//错
#include <bits/stdc++.h>
using namespace std;
const int N=30*2500;
char tmp[1];
int a[N],sai_zhi[2]={11,21},cnt;
int main(){
    while(1){
        cin>>tmp[0];
        if(tmp[0]=='E') break;
        else if(tmp[0]=='W') a[cnt++]=1;
        else a[cnt++]=0;
    }
    for(int i=0;i<2;i++){
        int win=0,lose=0;
        for(int j=0;j<cnt;j++){
            win+=a[j];
            lose+=1-a[j];
            if(max(win,lose)>=sai_zhi[i]&&abs(win-lose)>=2){
                printf("%d:%d\n",win,lose);
                win=lose=0;
            }    
        }
        printf("%d:%d\n\n",win,lose);
    }
    return 0;
}//对
2024/8/19 10:19
加载中...