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

王记输出impossible了WA一次,晕。

Posted by KatrineYang at 2016-08-03 14:26:21 on Problem 1753
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int hehe[4][4];
	char s[6];
	for(int i = 0; i < 4; i++){
		scanf("%s", s);
		for(int j = 0; j < 4; j++){
			hehe[i][j] = (s[j]=='b') ? 1 : 0;
		}
	}
	int res = 17;
	for(int state = 0; state < 65536; state++){
		if(state > 65536-(1<<(17-res))) break;
		int cnt = 0;
		int State[16];
		for(int i = 0; i < 16; i++){
			State[i] = ((state & (1<<i)) != 0);
			cnt += State[i];
		}
		if(cnt >= res) continue;
		int joZero = (hehe[0][0] + State[0] + State[1] + State[4]) % 2;
		bool keyi = true;
		for(int i = 1; i < 16; i++){
			int joI = hehe[i/4][i%4] + State[i];
			if(i > 3) joI += State[i-4];
			if(i < 12) joI += State[i+4];
			if(i%4 != 0) joI += State[i-1];
			if(i%4 != 3) joI += State[i+1];
			if(joI%2 != joZero%2){
				keyi = false;
				break;
			}
		}
		if(keyi){
			res = cnt;
		}
	}
	if(res < 17) printf("%d\n", res);
	else printf("Impossible\n");
	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