Codeforces Round #277.5 (Div. 2) D. Unbearable Controversy of Being
2014-11-18 11:30
471 查看
这个题明显自己把自己给恶心到了。
以为四个相同的点就算一个呢。 就写出一个没判重的 一直没敢交。。 后来赛后问了下, 才知道不需要判重。。 然后提交之后AC了。。
我也是醉了
这个题明显的深搜, 点 虽然多, 但是 就搜两层, 所以比较快, 不会超时, 从一个点 到 另一个点有多少种走法, 直接 C(n,2) 就可以了
还是比较简单的。
以为四个相同的点就算一个呢。 就写出一个没判重的 一直没敢交。。 后来赛后问了下, 才知道不需要判重。。 然后提交之后AC了。。
我也是醉了
这个题明显的深搜, 点 虽然多, 但是 就搜两层, 所以比较快, 不会超时, 从一个点 到 另一个点有多少种走法, 直接 C(n,2) 就可以了
还是比较简单的。
#include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #include <cmath> #include <cstdlib> #include <string> #include <map> #include <vector> #include <set> #include <queue> #include <stack> #include <cctype> using namespace std; typedef long long LL; typedef unsigned long long ULL; #define MAXN 10000+10 #define INF (1<<30) #define mod 123456789 vector <int> v[3010]; int vis[3010][3010] = {0}; int dfs(int i,int x, int time){ if(time == 3){ vis[i][x] ++; return 0; } int len = v[x].size(); for(int j = 0; j < len; j++){ dfs(i,v[x][j],time+1); } } int main (){ int n,t; scanf("%d%d",&n,&t); for(int j = 0; j < t; j++){ int x,y; scanf("%d%d",&x,&y); v[x].push_back(y); } for(int i = 1; i <= n; i++){ dfs(i,i,1); } LL sum = 0; for(int j = 1; j <= n; j++){ for(int k = 1; k <= n; k++){ if(vis[j][k] >= 2 && j != k){ sum += vis[j][k]*(vis[j][k]-1)/2; } } } printf("%I64d\n",sum); return 0; }
相关文章推荐
- Codeforces Round #277.5 (Div. 2)D Unbearable Controversy of Being (暴力)
- Codeforces Round #277.5 (Div. 2) D——Unbearable Controversy of Being
- Codeforces Round #277.5 (Div. 2)-D. Unbearable Controversy of Being
- Codeforces Round #277.5(Div. 2) D. Unbearable Controversy of Being【暴力】
- Codeforces Round #277.5 (Div. 2) D - Unbearable Controversy of
- Codeforces Round #277.5 (Div. 2)C. Given Length and Sum of Digits...(贪心)
- Codeforces Round #277.5 (Div. 2) C. Given Length and Sum of Digits...
- Codeforces Round #277.5 (Div. 2)C. Given Length and Sum of Digits...(贪心)
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
- Codeforces Round #277.5 (Div. 2)——C贪心—— Given Length and Sum of Digits
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
- Codeforces Round #277.5 (Div. 2)-C. Given Length and Sum of Digits...
- Codeforces Round #277.5(Div. 2) C. Given Length and Sum of Digits...【贪心】
- Unbearable Controversy of Being CodeForces - 489D
- Codeforces Round #277.5 (Div. 2) C. Given Length and Sum of Digits...
- Codeforces Round #377 (Div. 2) Cormen --- The Best Friend Of a Man
- Codeforces Round #437 (Div. 2 C. Ordering Pizza 贪心 only two types of pizza
- Codeforces Round #277.5 (Div. 2)---B. BerSU Ball (贪心)
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- Codeforces Round #277.5 (Div. 2) A B C D