#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long LL;
#define pb push_back
const int N = 1e6 + 10;
constexpr int base = 1 << 20;
int tab[200][200];
int cnt[200][200];
unordered_map<string, bool> visited;
bool pierwsze[N];
void sito(int n)
{
for(int i=1;i<=n;i++)
pierwsze[i] = true;
pierwsze[0] = pierwsze[1] = false;
for(int i=2;i<=n;i++)
{
if(pierwsze[i])
for(int j=2*i;j<=n;j+=i)
pierwsze[j] = false;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int A = 100;
int wyn = 0, id = 0;
for(int y=82334;y<=82334;y++)
{
mt19937 gen(y);
string s1;
for(int i=1;i<=A;i++)
{
string s;
for(int j=1;j<=A;j++)
{
int x = 0;
if(i==1 && j==1) x = 1;
if(i==1 && j != 1) x = 0;
if(i==2 && j <= A-1) x = 1;
if(i==2 && j == A) x = 0;
if(3 <= i && i <= A-1) x = j%2;
if(i==A && j==A) x = 1;
tab[i][j] = x;
s += to_string(x);
}
s1 += s;
}
for(int i=1;i<=A;i++)
{
for(int j=1;j<=A;j++)
cout << tab[i][j];
cout << endl;
}
return 0;
int res = 1;
visited[s1] = true;
s1.clear();
while(true)
{
for(int i=1;i<=A-1;i++)
{
for(int j=1;j<=A-1;j++)
{
if((tab[i][j] && tab[i+1][j+1] && !tab[i+1][j] && !tab[i][j+1])
|| (!tab[i][j] && !tab[i+1][j+1] && tab[i+1][j] && tab[i][j+1]))
{
cnt[i][j]++;
cnt[i+1][j]++;
cnt[i][j+1]++;
cnt[i+1][j+1]++;
}
}
}
string s;
for(int i=1;i<=A;i++)
{
for(int j=1;j<=A;j++)
{
if(cnt[i][j]) tab[i][j] = !tab[i][j];
cnt[i][j] = 0;
int x = tab[i][j];
s += to_string(x);
}
}
if(!visited[s]){
res++;
visited[s] = true;
}
else break;
}
// cout << y << " " << res << endl;;
visited.clear();
if(res > wyn)
{
wyn = res;
id = y;
}
}
cout << wyn;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #include <bits/stdc++.h> #include <random> using namespace std; typedef long long LL; #define pb push_back const int N = 1e6 + 10; constexpr int base = 1 << 20; int tab[200][200]; int cnt[200][200]; unordered_map<string, bool> visited; bool pierwsze[N]; void sito(int n) { for(int i=1;i<=n;i++) pierwsze[i] = true; pierwsze[0] = pierwsze[1] = false; for(int i=2;i<=n;i++) { if(pierwsze[i]) for(int j=2*i;j<=n;j+=i) pierwsze[j] = false; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int A = 100; int wyn = 0, id = 0; for(int y=82334;y<=82334;y++) { mt19937 gen(y); string s1; for(int i=1;i<=A;i++) { string s; for(int j=1;j<=A;j++) { int x = 0; if(i==1 && j==1) x = 1; if(i==1 && j != 1) x = 0; if(i==2 && j <= A-1) x = 1; if(i==2 && j == A) x = 0; if(3 <= i && i <= A-1) x = j%2; if(i==A && j==A) x = 1; tab[i][j] = x; s += to_string(x); } s1 += s; } for(int i=1;i<=A;i++) { for(int j=1;j<=A;j++) cout << tab[i][j]; cout << endl; } return 0; int res = 1; visited[s1] = true; s1.clear(); while(true) { for(int i=1;i<=A-1;i++) { for(int j=1;j<=A-1;j++) { if((tab[i][j] && tab[i+1][j+1] && !tab[i+1][j] && !tab[i][j+1]) || (!tab[i][j] && !tab[i+1][j+1] && tab[i+1][j] && tab[i][j+1])) { cnt[i][j]++; cnt[i+1][j]++; cnt[i][j+1]++; cnt[i+1][j+1]++; } } } string s; for(int i=1;i<=A;i++) { for(int j=1;j<=A;j++) { if(cnt[i][j]) tab[i][j] = !tab[i][j]; cnt[i][j] = 0; int x = tab[i][j]; s += to_string(x); } } if(!visited[s]){ res++; visited[s] = true; } else break; } // cout << y << " " << res << endl;; visited.clear(); if(res > wyn) { wyn = res; id = y; } } cout << wyn; } |
English