#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define nl printf("\n")
#define case(a,b) printf("Case %lld: %lld\n",a,b)
#define P(a) printf("%lld\n",a)
#define SP(a) printf("%lld ",a)
#define G(a) scanf("%lld",&a)
#define GG(a,b) scanf("%lld %lld",&a,&b)
#define pb push_back
#define DB printf("I WAS HERE\n")
#define SPP(a,b) printf("%lld %lld\n",a,b)
#define LL long long
int main()
{
long long t;
G(t);
while(t--)
{
LL n;
G(n);
long long ar[12]={0},ar2[12]={0};
char r[10];
long long i,j,d,s,cnt=0;
for(i=1;i<=n;i++)
{
scanf("%lld %lld %s",&d,&s,r);
if(s==0 && r[0]=='i')
{
ar[d]++;
}
else if(s==1 && r[0]=='c')
{
ar2[d]++;
}
}
cnt=0;
for(i=1;i<=9;i++)
{
for(j=i+1;j<=10;j++)
{
LL x=ar[i]*ar2[j];
cnt+=x;
}
}
P(cnt);
}
return 0;
}
#include<cstring>
using namespace std;
#define nl printf("\n")
#define case(a,b) printf("Case %lld: %lld\n",a,b)
#define P(a) printf("%lld\n",a)
#define SP(a) printf("%lld ",a)
#define G(a) scanf("%lld",&a)
#define GG(a,b) scanf("%lld %lld",&a,&b)
#define pb push_back
#define DB printf("I WAS HERE\n")
#define SPP(a,b) printf("%lld %lld\n",a,b)
#define LL long long
int main()
{
long long t;
G(t);
while(t--)
{
LL n;
G(n);
long long ar[12]={0},ar2[12]={0};
char r[10];
long long i,j,d,s,cnt=0;
for(i=1;i<=n;i++)
{
scanf("%lld %lld %s",&d,&s,r);
if(s==0 && r[0]=='i')
{
ar[d]++;
}
else if(s==1 && r[0]=='c')
{
ar2[d]++;
}
}
cnt=0;
for(i=1;i<=9;i++)
{
for(j=i+1;j<=10;j++)
{
LL x=ar[i]*ar2[j];
cnt+=x;
}
}
P(cnt);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন