/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
set<int> G[1001] ;
int visited[1001] ;
int main()
{
int test ,cnt,i,j;
sc("%d",&test) ;
char ch[51] ;
getchar() ;
while(test--)
{
int p,t ,x,y;
sc("%d %d",&p,&t) ;
memset(visited,0,sizeof(visited)) ;
for(i=1 ; i<=p ; i++)
G[i].clear() ;
getchar() ;
while(gets(ch))
{
if(strlen(ch)==0)
break ;
stringstream str (ch) ;
str>>x>>y ;
G[x].insert(y) ;
}
cnt =0 ;
for(i=1 ; i<=p ; i++)
{
if(!visited[i])
{
cnt++ ;
for(j= i+1 ; j<=p ; j++)
{
if(G[i]==G[j])
{
visited[j] =1 ;
}
}
}
}
pf("%d\n",cnt) ;
if(test)
pf("\n") ;
}
return 0;
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
set<int> G[1001] ;
int visited[1001] ;
int main()
{
int test ,cnt,i,j;
sc("%d",&test) ;
char ch[51] ;
getchar() ;
while(test--)
{
int p,t ,x,y;
sc("%d %d",&p,&t) ;
memset(visited,0,sizeof(visited)) ;
for(i=1 ; i<=p ; i++)
G[i].clear() ;
getchar() ;
while(gets(ch))
{
if(strlen(ch)==0)
break ;
stringstream str (ch) ;
str>>x>>y ;
G[x].insert(y) ;
}
cnt =0 ;
for(i=1 ; i<=p ; i++)
{
if(!visited[i])
{
cnt++ ;
for(j= i+1 ; j<=p ; j++)
{
if(G[i]==G[j])
{
visited[j] =1 ;
}
}
}
}
pf("%d\n",cnt) ;
if(test)
pf("\n") ;
}
return 0;
}
No comments:
Post a Comment