POJ 1250
1 #include<iostream> 2 #include<set> 3 #include<string> 4 using namespace std; 5 6 set<char> coll; 7 set<char>::iterator pos; 8 9 int main() 10 { 11 //freopen("acm.acm","r",stdin); 12 int n; 13 int i; 14 int man_now; 15 int len; 16 int ans; 17 string s; 18 while(cin>>n,n) 19 { 20 man_now = 0; 21 ans = 0; 22 getchar(); 23 getline(cin,s); 24 //cout<<s<<endl; 25 len = s.length(); 26 for(i = 0; i < len; ++ i) 27 { 28 pos = coll.find(s[i]); 29 if(pos == coll.end()) 30 { 31 coll.insert(s[i]); 32 //++ man_now; 33 if(coll.size() > n) 34 { 35 ++ ans; 36 } 37 } 38 else 39 { 40 coll.erase(s[i]); 41 // -- man_now; 42 } 43 } 44 if(ans == 0) 45 { 46 cout<<"All customers tanned successfully."<<endl; 47 } 48 else 49 { 50 cout<<ans<<" customer(s) walked away."<<endl; 51 } 52 } 53 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com