首页 > 代码库 > Codeforces Round #371 (Div. 2) C
Codeforces Round #371 (Div. 2) C
传送门
map或者字典数的应用 简单题
题意:
思路:
AC代码:
1 #include<iostream> 2 #include<cstring> 3 #include<cmath> 4 #include<map> 5 #include<algorithm> 6 #include<cstdio> 7 #define max(a,b) a>b?a:b 8 #define F(i,a,b) for(int i=a;i<=b;i++) 9 #define mes(a,b) memset(a,b,sizeof(a))10 #define INF 0x3f3f3f3f11 #define LL long long12 using namespace std;13 const int N=10010,MAX=1000100;14 15 void fun(char *s)16 {17 int l = 0;18 for(int i=0; i<strlen(s); i++)19 {20 if(s[i] == ‘0‘)21 l++;22 else23 break;24 }25 for(int i=l-1; i<=strlen(s); i++)26 {27 s[i-l+1] = s[i+1];28 }29 if(*s == ‘\0‘)30 {31 *s = ‘0‘;32 s[1] = ‘\0‘;33 }34 }35 36 int main()37 {38 int n;39 char c,s[20];40 map<string,int>M;41 scanf("%d",&n);42 while(n--)43 {44 cin>>c>>s;45 int l = strlen(s);46 for(int i=0; i<l; i++)47 {48 if(s[i]&1)49 s[i] = ‘1‘;50 else51 s[i] = ‘0‘;52 }53 //puts(s);54 fun(s);55 //puts(s);56 if(c == ‘+‘)57 M[s]++;58 if(c == ‘-‘)59 M[s]--;60 if(c == ‘?‘)61 cout<<M[s]<<endl;62 }63 return 0;64 }
Codeforces Round #371 (Div. 2) C
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。