8/9三角形
直接map就好了,先把abc排序,关键字开ll,等于a×10000×10000+b×10000+c;
然后直接查就好了
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<float.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define sf scanf
#define pf printf
#define scf(x) scanf("%d",&x)
#define scff(x,y) scanf("%d%d",&x,&y)
#define scfff(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define prf(x) printf("%d\n",x)
#define mm(x,b) memset((x),(b),sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const ll mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
using namespace std;
const double pi=acos(-1.0);
const int N=1e4+10;
map<ll,int> v;
ll init()
{
ll a,b,c;cin>>a>>b>>c;
if(a>b)
swap(a,b);
if(a>c)
swap(a,c);
if(b>c)
swap(b,c);
return a*100000000+b*10000+c;
}
int main()
{
map<ll, int>::iterator t;
int n;scf(n);
ll k;
rep(i,0,n)
{
k=init();
t=v.find(k);
if(t!=v.end())
{
t->se ++;
}else
{
v.insert(mp(k,1));
}
}
int m;scf(m);
while(m--)
{
k=init();
t=v.find(k);
if(t!=v.end())
prf(t->se);
else
pf("0\n");
}
return 0;
}