Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
41521 Xiyou 评选最佳品牌 C++ 通过 1 MS 256 KB 1232 2024-02-21 18:37:38

Tests(2/2):


#include<bits/stdc++.h> using namespace std; int g[1010][15]; int piao[15]; bool st[15]; bool success=true; int last_pi; int last_pn; int n,m; void ping_xuan(){ while(true){ memset(piao,0,sizeof(piao)); for(int i=1;i<=n;i++){ for(int j=1;j<m;j++){ int k=g[i][j]; if(k==0){ break; } if(st[k]){ continue; } piao[k]++; break; } } int minn=1001,maxn=-1001; for(int i=1;i<m;i++){ if(piao[i]<minn&&!st[i]){ minn=piao[i]; } if(piao[i]>maxn&&!st[i]){ maxn=piao[i]; } } if(maxn>minn){ for(int i=1;i<m;i++){ if(piao[i]==minn&st[i]==false){ st[i]=true; } } continue; }else{ int sum=0; for(int i=1;i<=m;i++){ if(piao[i]==minn){ sum++; last_pn=i; } } if(sum==1){ return; } else{ last_pi=minn; success=false; return ; } } } } int main(){ cin>>m>>n; for(int i=1;i<=n;i++){ string str; cin>>str; for(int j=0;j<str.size();j++){ g[i][j+1]=str[j]-'0'; } } ping_xuan(); if(success){ cout<<last_pn; }else{ cout<<"-"<<last_pi; } return 0; }


测评信息: