HDU 6313 Hack It (循环加群构造)

Posted xuejye

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 6313 Hack It (循环加群构造)相关的知识,希望对你有一定的参考价值。

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6313

Hack It

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 982    Accepted Submission(s): 339
Special Judge

 

Problem Description

Tonyfang is a clever student. The teacher is teaching he and other students "bao'sou".
The teacher drew an n*n matrix with zero or one filled in every grid, he wanted to judge if there is a rectangle with 1 filled in each of 4 corners.
He wrote the following pseudocode and claim it runs in O(n2):

let count be a 2d array filled with 0s
iterate through all 1s in the matrix:
  suppose this 1 lies in grid(x,y)
  iterate every row r:
    if grid(r,y)=1:
      ++count[min(r,x)][max(r,x)]
      if count[min(r,x)][max(r,x)]>1:
        claim there is a rectangle satisfying the condition
claim there isn't any rectangle satisfying the condition



As a clever student, Tonyfang found the complexity is obviously wrong. But he is too lazy to generate datas, so now it's your turn.
Please hack the above code with an n*n matrix filled with zero or one without any rectangle with 1 filled in all 4 corners.
Your constructed matrix should satisfy 1≤n≤2000 and number of 1s not less than 85000.

 

 

Input

Nothing.

 

 

Output

The first line should be one positive integer n where 1≤n≤2000.

n lines following, each line contains only a string of length n consisted of zero and one.

 

 

Sample Input

 

(nothing here)

 

 

Sample Output

 

3 010 000 000 (obviously it's not a correct output, it's just used for showing output format)

 

 

Source

2018 Multi-University Training Contest 2

 2000*2000看成某个质数的四次方 也就是47

为什么是四次方  因为可以把整个矩阵看成47*47个47*47的小方阵

小方阵里就是通常加法意义下模47的循环加群

如果模的是合数循环群表上会有某几行是重复的结果 数论书上有。。

枚举加值和起始位置就可构造出47*47个小方阵

听视频讲解之后反应过来然后反思自己为什么这么菜。。

 

理解是个循环加群之后就很好写代码了。。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <algorithm>
#define max_ 47
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
int main()

    //freopen("data.txt","w",stdout);
    cout <<"2000" <<endl;
    for(int i=1;i<=47;i++)//cong i kai shi
    
        for(int j=1;j<=47;j++)//bu chang
        
            int mid=i;
            int cnt=0;
            for(int k=1;k<=47;k++)
            
                mid=(mid+j)%47;
                for(int l=0;l<47;l++)
                
                    if(l==mid)
                        cout << "1";
                    else
                        cout <<"0";
                    cnt++;
                    if(cnt==2000)
                        break;
                
                if(cnt==2000)
                    break;
            
            cout << endl;
        
        cout <<endl;
    

 

以上是关于HDU 6313 Hack It (循环加群构造)的主要内容,如果未能解决你的问题,请参考以下文章

HDU 6313: Hack it

CodeForces - 468C Hack it!(构造+数位dp)

CodeForces - 468C Hack it!(构造+数位dp)

Hack It

任意两个无限阶循环群之间的映上同态总是同构的

(You Can Hack It, Architecture and Design) => { Dependency Injection; }