Skip to content

Instantly share code, notes, and snippets.

@Izaron
Created May 18, 2022 13:29
Show Gist options
  • Save Izaron/699c89d5449f65291fe96ba85fe8ac0c to your computer and use it in GitHub Desktop.
Save Izaron/699c89d5449f65291fe96ba85fe8ac0c to your computer and use it in GitHub Desktop.
exclusively for t.me/cxx95
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
void diffize(vector<int>& vec1, vector<int>& vec2, int s) {
int m = vec1.size();
int diffs = 0;
for (int i = 0; i < m; ++i) {
if (vec1[i] != vec2[i]) {
++diffs;
}
}
while (diffs < 3) {
++diffs;
int ind = -1;
while (ind < 0 || vec1[ind] != vec2[ind]) {
ind = rnd.next(m);
}
while (vec1[ind] == vec2[ind]) {
vec2[ind] = rnd.next(1, s);
}
}
}
int main(int argc, char **argv) {
registerGen(argc, argv, 1);
int n = atoi(argv[1]);
int m = atoi(argv[2]);
int s = atoi(argv[3]);
// initial answer
vector<int> answer(m);
for (int i = 0; i < m; ++i) {
answer[i] = rnd.next(1, s);
}
// the answer is NO
vector<vector<int>> ans;
for (int i = 0; i < n; ++i) {
int ind = rnd.next(m);
int prev = answer[ind];
while (answer[ind] == prev) {
answer[ind] = rnd.next(1, s);
}
ans.push_back(answer);
answer[ind] = prev;
}
int ind1 = rnd.next(n);
int ind2 = ind1;
while (ind1 == ind2) {
ind2 = rnd.next(n);
}
diffize(ans[ind1], ans[ind2], s);
cout << n << " " << m << endl;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cout << ans[i][j];
if (j != m - 1) {
cout << " ";
}
}
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment