?? 1678.cpp
字號:
/* This Code is Submitted by wywcgs for Problem 1678 on 2006-03-11 at 02:52:32 */
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 512;
int status[MAX];
bool win[MAX][MAX];
void up(int, int);
int main()
{
int i, j, case_no, n;
for(case_no = 0; scanf("%d", &n) != EOF && n != 0; case_no++) {
if(case_no != 0) putchar('\n');
int pn = 1 << n;
for(i = pn-1; i < 2*pn-1; i++) status[i] = i - pn + 2;
for(i = n-1; i >= 0; i--)
for(j = (1<<i)-1; j < (1<<i+1)-1; j++)
scanf("%d", &status[j]);
memset(win, false, sizeof(win));
for(i = 0; i < 1<<n; i++) up(pn-1+i, pn-1+i);
int t, T; scanf("%d", &T);
for(t = 0; t < T; t++) {
int e; scanf("%d", &e);
int best = 0, worst = 0;
for(i = 1; i <= pn; i++) {
if(i == e) continue;
if(win[e][i]) best++;
if(win[i][e]) worst++;
}
printf("Player %d can be ranked as high as %d or as low as %d.\n", e, worst+1, pn-best);
}
}
return 0;
}
void up(int o, int b)
{
win[status[o]][status[b]] = true;
if(o == 0) return;
else up((o-1)/2, b);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -