http://codeforces.com/contest/5

A

模拟题

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 typedef long long ll;
 7 /*#ifndef ONLINE_JUDGE
 8         freopen("1.txt","r",stdin);
 9 #endif */
10 
11 
12 int main(){
13     std::ios::sync_with_stdio(false);
14     #ifndef ONLINE_JUDGE
15         freopen("1.txt","r",stdin);
16     #endif
17     set<string>se;
18     string str;
19     int i;
20     int ans=0;
21     while(getline(cin,str)){
22         if(str.length()==0) break;
23         if(str[0]=='+'||str[0]=='-'){
24             if(str[0]=='+'){
25                 str=str.substr(1);
26                 se.insert(str);
27             }
28             else{
29                 str=str.substr(1);
30                 se.erase(str);
31             }
32         }
33         else{
34             for(i=0;i<str.length();i++){
35                 if(str[i]==':') break;
36             }
37            // cout<<i<<endl;
38             ans+=se.size()*(str.length()-1-i);
39         }
40     }
41     cout<<ans<<endl;
42     return 0;
43 }
View Code

相关文章:

  • 2022-02-11
  • 2021-10-11
  • 2021-09-06
  • 2021-05-27
  • 2021-12-21
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2021-05-23
相关资源
相似解决方案