U E D R , A S I H C RSS

FOURGODS/김태진

  • *
  • A-B-C-D(-A)
    • .
  • A C .(n^2)
    • B D .(A,C ) (n)
    • 토탈 n^3
  • . A-B-C-D .(e.g. )
    • A . B C , A-B-C-D A-C-B-D .

//
//  fourgods.cpp
//  codersHigh2013
//
//  Created by Jereneal Kim on 13. 8. 6..
//  Copyright (c) 2013 Jereneal Kim. All rights reserved.
//

#include <iostream>
using namespace std;
int T,N,M;
int arr[501][501];
typedef struct Edge{
	int u;
	int v;
}Edge;
bool comp(Edge a,Edge b){
	if(a.u!=b.u){
		return a.u<b.u;
	}else{
		return a.v<b.v;
	}
}


int main(int argc, const char * argv[])
{
	freopen("/Users/jkim/Development/C&C++/codersHigh2013/codersHigh2013/input.txt","r",stdin);
	int i,j,k,num;
	scanf("%d",&T);
	for(int iter=0;iter<T;iter++){
		num=0;
		for(i=0;i<500;i++){
			for(j=0;j<500;j++){
				arr[i][j] = 0;
			}
		}//initalize
		
		scanf("%d %d",&N,&M);
		for(i=0;i<M;i++){
			int tmp1,tmp2;
			scanf("%d %d",&tmp1,&tmp2);
			arr[tmp2][tmp1] = 1;
			arr[tmp1][tmp2] = 1;
		}
		// get A & C
		for(i=1;i<=N;i++){
			for(k=i+1;k<=N;k++){
				int tmpNum=0;
				for(j=i+1;j<=N;j++){
					if(arr[i][j]&&arr[j][k]){
						tmpNum++;
					}
				}
				num+=tmpNum*(tmpNum-1)/2;
				num%=20130728;
			}
		}

		printf("%d\n",num);
	}
    return 0;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:15
Processing time 0.0084 sec