Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
這麽個水題竟然嚷盎一次rt #include <iostream> #include <stdio.h> #include <vector> using namespace std; int N; int main() { while(scanf("%d", &N) > 0){ if(N == 0) break; int H[300] = {0}, win[300] = {0}; vector<int> data; for(int i = 1; i <= N; i++){ for(int j = 0; j < (1 << (N-i)); j++){ int temp; scanf("%d", &temp); if(i != N) data.push_back(temp); H[temp] = i; } } int sz = data.size(); for(int i = 1; i <= (1<<N); i+=2){ if(H[i] == 0) win[i] = i+1; else win[i+1] = i; } for(int i = 0; i < sz-1; i+=2){ if(H[data[i]] > H[data[i+1]]) win[data[i+1]] = data[i]; else win[data[i]] = data[i+1]; } //for(int i = 1; i <= (1<<N); i++) cout << win[i] << " "; cout << endl; int qgs; scanf("%d", &qgs); for(int i = 0; i < qgs; i++){ int q; scanf("%d", &q); int Q = q; int low, high = 1; low = (1<<N) - (1<<H[q]) + 1; while(win[q] != 0){ high++; q = win[q]; } printf("Player %d can be ranked as high as %d or as low as %d.\n", Q, high, low); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator