Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
41550 lmz120809 评选最佳品牌 C++ 解答错误 0 MS 264 KB 1132 2024-02-21 19:00:45

Tests(1/2):


#include<bits/stdc++.h> using namespace std; int g[1010][15]; int piao[15]; bool st[15]; bool stuccess=true; int last_piaoshu; int last_pinpai; int n,m; void pingxuan() { while(1){ memset(piao,0,sizeof(piao)); for(int i=1;i<=n;i++){ for(int j=1;i<=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_pinpai=i; } if(sum==1) return; else{ last_piaoshu=minn; stuccess=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'; } } pingxuan(); if(stuccess) cout<<last_pinpai<<endl; else cout<<'-'<<last_piaoshu<<endl; return 0; }


测评信息: