提交时间:2022-08-03 14:41:36

运行 ID: 56789

#include<bits/stdc++.h> using namespace std; int a[4],n,x,y; int check(char c){ if(c=='D') return 1; if(c=='G') return 2; if(c=='Z') return 3; return 0; } char c1,c2,sb; int main(){ cin>>n; while(n--){ cin>>c1/*>>sb*/>>c2; x=check(c1),y=check(c2); a[x]++,a[y]--; } cout<<"D "<<a[1]<<endl; cout<<"G "<<a[2]<<endl; cout<<"Z "<<a[3]<<endl; return 0; }