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

Re:一个简单巧妙的解法 469B 32ms

Posted by emptypoint at 2017-10-03 11:21:33 on Problem 2965
In Reply To:一个简单巧妙的解法 469B 32ms Posted by:416221843 at 2016-08-03 15:53:34
> 学习于某大神的博客
> 首先 把某开关同行同列的所有开关动1遍 结果是只有该开关变化 其他开关不变化
> 策略就是如果1个开关是关的 就把他同行同列的所有开关动1遍 而一个开关操作偶数次相当于没有操作 只要模拟出上述过程统计一下操作奇数次的开关有多少就好
> #include<stdio.h>
> #include<string.h>
> int main()
> {bool b[4][4];int i, j, k, a = 0;
> char q; memset(b, 0, sizeof(b));
> for (i = 0; i < 4; i++)
> {for (j = 0; j < 4; j++)
> {scanf("%c", &q); if (q == '+') {
> for (k = 0; k < 4; k++) b[i][k]=!b[i][k], b[k][j]=!b[k][j];
> b[i][j]=!b[i][j];}
> }getchar();}
> for (i = 0; i < 4; i++)
> for (j = 0; j < 4; j++)
> if (b[i][j]) a++;
> printf("%d\n", a);
> for (i = 0; i < 4; i++)
> for (j = 0; j < 4; j++)
> if (b[i][j]) printf("%d %d\n", i + 1, j + 1);}

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