提交时间:2022-08-03 17:00:59

运行 ID: 56928

#include<bits/stdc++.h> using namespace std; char fi,ei; int n; int dd=0,gg=0,zz=0; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>fi>>ei; if(fi=='D'){ dd+=1; } if(fi=='G'){ gg+=1; } if(fi=='Z'){ zz+=1; } if(ei=='D'){ dd-=1; } if(ei=='G'){ gg-=1; } if(ei=='Z'){ zz-=1; } } cout<<"D"<<" "<<dd<<endl; cout<<"G"<<" "<<gg<<endl; cout<<"Z"<<" "<<zz<<endl; return 0; }