zoukankan      html  css  js  c++  java
  • Hack It

    Hack It

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 373    Accepted Submission(s): 104
    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 1n2000 and number of 1s not less than 85000.
     
    Input
    Nothing.
     
    Output
    The first line should be one positive integer n where 1n2000.

    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
     

    这题是真的强,不晓得大佬是怎么想出来的.

     1 #include <iostream>
     2 #include <cstring>
     3 #include <stdio.h>
     4 #include <algorithm>
     5 using namespace std;
     6 int ans[3000][3000];
     7 int n=47;
     8 int main(){
     9   for(int i=0;i<n;i++){
    10     for(int j=0;j<n;j++){
    11       int tmp=j;
    12       for(int k=0;k<n;k++){
    13         if(k!=0)tmp+=i;
    14         tmp%=n;
    15         ans[k*n+tmp][i*n+j]=1;
    16       }
    17     }
    18   }
    19   cout<<2000<<endl;
    20   for(int i=0;i<2000;i++){
    21       for(int j=0;j<2000;j++){
    22         cout<<ans[i][j];
    23       }
    24       cout<<endl;
    25   }
    26   return 0;
    27 }
  • 相关阅读:
    威胁情报网站
    python3实现telnet查看IP地址段端口开放情况
    python3实现指定IP多线程端口扫描
    安全网址导航
    python3调用exe程序编写cve20190708批量检测工具
    python3爬取网页中的邮箱地址
    黑客马拉松
    Nginx自定义模块编写:根据post参数路由到不同服务器
    Apache HTTP Server 与 Tomcat 的三种连接方式介绍
    Apache HTTP Server 与 Tomcat 的三种连接方式介绍
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/9369136.html
Copyright © 2011-2022 走看看