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 |
K<=11, shuzukai2048keyiguo#include <iostream> #include <stdio.h> using namespace std; int data[2048][2048]; int mn(int a, int b){ return (a<b) ? a : b; } int mn4(int a, int b, int c, int d){ return mn(mn(a, b), mn(c,d)); } int main() { int t; scanf("%d", &t); for(int ii = 0; ii < t; ii++){ int k; scanf("%d", &k); int K = (1 << k); for(int i = 0; i < K; i++){ for(int j = 0; j < K; j++){ scanf("%d", &data[i][j]); } } int cnt = 0; for(int q = 0; q < k; q++){ K /= 2; for(int i = 0; i < K; i++){ for(int j = 0; j < K; j++){ int mnn = mn4(data[2*i][2*j], data[2*i][2*j+1], data[2*i+1][2*j], data[2*i+1][2*j+1]); cnt += (data[2*i][2*j]+data[2*i][2*j+1]+data[2*i+1][2*j]+data[2*i+1][2*j+1]-4*mnn+4); data[i][j] = mnn; } } } printf("%d\n", cnt + data[0][0] + 1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator