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

2^16 暴力能过 704ms

Posted by 947186602 at 2020-09-18 11:07:01 on Problem 2965 and last updated at 2020-09-18 11:17:16
枚举所有状态,暴力过了再谈优化···


找规律 对于一个+,反转该行+该列所有值,发现只有+这个位置会反转7次,其他都是4次,意味着只有自己变其他不变
所以我们遇到+就进行上述操作,最后将结果%2,因为偶数操作不必要,输出反转为奇数的结果即可 16ms
————————————————————————————
for(int i = 0; i < 4; ++i)
    {
        scanf("%s",game[i]);
        for(int j = 0; j < 4; ++j)
        {
            if(game[i][j] == '+') 
            {
               ans[i][0]++;
               ans[i][1]++;
               ans[i][2]++;
               ans[i][3]++;
               ans[0][j]++;
               ans[1][j]++;
               ans[2][j]++;
               ans[3][j]++;
               ans[i][j]--;
            }
        }
    }
    int now = 0;
    for(int i = 0;i < 4;++i){
          for(int j = 0;j < 4;++j)
               if(ans[i][j] & 1) now++;
    }
    printf("%d\n",now);
    for(int i = 0;i < 4;++i){
          for(int j = 0;j < 4;++j)
               if(ans[i][j] & 1)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