Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
42170 Xiyou 森林之王 C++ 解答错误 0 MS 256 KB 546 2024-02-24 11:34:16

Tests(0/1):


#include<bits/stdc++.h> using namespace std; string s[20]={}; int a[20]; int n,m,j=0,cnt; int main(){ cin>>n>>m; for(int i=0;i<n;i++){ cin>>s[i]; if(s[i]=="tiger"||s[i]=="lion"||s[i]=="dinosaur"){ a[i]=3; }else{ a[i]=1; } } cnt=n; int l=0; while(cnt>1){ if(a[l]>0){ j++; } if(j==m){ a[l]--; if(a[l]==0){ cnt--; } j=0; } l++; l%=10; } for(int i=0;i<n;i++){ if(a[i]){ cout<<"森林之王是: "<<s[i]; } } return 0; }


测评信息: