Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

K<=11, shuzukai2048keyiguo

Posted by KatrineYang at 2016-09-18 12:42:53 on Problem 1342
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator