hdu 2538 确定排名
来源:互联网 发布:建筑软件行业 编辑:程序博客网 时间:2024/05/20 07:52
。。。。。。。。。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <vector>#include <queue>using namespace std;#define REP(i,s,t) for(int (i)=(s);(i)<=(t);++(i))#define UREP(i,s,t) for(int (i)=(s);(i)>=(t);--(i))#define INF 0x7FFFFFFFconst double eps = 1e-10;const int maxn = 30;int cnt[maxn][maxn], arr[maxn], a[maxn], b[maxn];int t[maxn];int r[maxn], id[maxn];int n;double base;bool cmp(int lhs, int rhs) { return t[lhs] > t[rhs];}void dfs(int now, int tot) { if (now > tot) { for (int i=1;i<=n;++i) id[i] = i; sort(id+1, id+n+1, cmp); int idx = 1; r[1] = 1; for (int i=2;i<=n;++i) { if (t[id[i]] < t[id[i-1]]) r[id[i]] = (idx = i); else r[id[i]] = idx; } for (int i=1;i<=n;++i) cnt[i][r[i]]++;/* printf("\n"); for (int i=1;i<=n;++i) printf("%d ", t[i]); printf("\n"); for (int i=1;i<=n;++i) printf("%d ", r[i]); printf("\n"); printf("\n");*/ base += 1; return; } int x = a[now], y = b[now]; t[x] = arr[x] + 1; t[y] = arr[y]; dfs(now+1, tot); t[x] = arr[x]; t[y] = arr[y] + 1; dfs(now+1, tot);}int main() { freopen("input.in", "r", stdin); char buf[10]; while (scanf("%d",&n) && n) { for (int i=1;i<=n;++i) scanf("%d",&arr[i]); for (int i=1;i<=n/2;++i) { scanf("%d-%d",&a[i], &b[i]); } memset(cnt, 0, sizeof(cnt)); base = 0; dfs(1, n/2); /* for (int i=1;i<=n;++i) { for (int j=1;j<=n-1;++j) { printf("%d ", cnt[i][j]); } printf("%d\n", cnt[i][n]); }*/ //double base = 1; //cout << base << endl; for (int i=1;i<=n;++i) { for (int j=1;j<=n-1;++j) { printf("%.5f ", (double)cnt[i][j]/base); } printf("%.5f\n", (double)cnt[i][n]/base); } } return 0;}
0 0
- hdu 2538 确定排名
- 排名确定
- hdu 1285 确定比赛排名(拓扑排序)
- HDU 1811 Rank of Tetris(拓扑排序确定排名,排名有重复的情况)
- HDU 5131 Song Jiang's rank list (确定排名经典问题)
- hdu 排名
- HDU 确定比赛名次
- hdu 确定比赛名次
- 确定比赛名次 HDU
- 确定比赛名次 HDU
- 考试排名 hdu 2903
- hdu 2093 考试排名
- HDU 1236 排名
- HDU 2093 - 考试排名
- HDU-1236 排名
- HDU 2093 考试排名
- HDU 1236 ( 排名 )
- HDU 2093 考试排名
- jni方法动态注册--C++
- ubuntu,eclipse下用maven创建hadoop项目总结
- 软件架构概念
- membership(4)---API篇
- 网络相关知识
- hdu 2538 确定排名
- Android Handler详解
- 3DSMAX中英文对照大全(从A-Z分类)
- PLSQL使用技巧
- CGI编程入门--GET与POST示例
- xcode 工具设置
- 简单有效的Unity3D分辨率适应教程
- 陪女儿打造的简单显微镜
- 过河卒,茶人故事