fastle
垆边人似月 皓腕凝霜雪
/*
以现在的机器速度, 不使用bitset的暴力是能跑到75分的
考虑在取模意义下的特殊情况, 维护a数组的每一维的前缀和,整体来做, 那么在一次统计中得不到一个答案的概率是$\frac{1}{2}$
至于取mod为三的情况 我们发现虽然mod不为0的情况可能是1 或者2 但是他们两个在mod3 意义下平方后都是1
按照这个性质维护即可
 
*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#define ll long long
#define M 100010
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int a[M][105], n, d, k, rd[M], tmp[105][105], tmd[105];


int work(int now) {
	int ans = 0;
	if(k == 2) {
		for(int i = 1; i <= d; i++) {
			ans ^= a[now][i] * tmd[i];
			tmd[i] ^= a[now][i];
		}
	} else {
		for(int i = 1; i <= d; i++)
			for(int j = 1; j <= d; j++) {
				ans += a[now][i] * a[now][j] * tmp[i][j];
				tmp[i][j] += a[now][i] * a[now][j];
			}
	}
	return ans % k;
}


bool check(int i, int j) {
	int ans = 0;
	for(int z = 1; z <= d; z++) ans += a[i][z] * a[j][z];
	ans %= k;
	return ans == 0;
}

int main() {
	srand(20020216);
	n = read(), d = read(), k = read();
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= d; j++)
			a[i][j] = read() % k;
	}
	for(int i = 1; i <= n; i++) rd[i] = i;
	for(int T = 1; T; T--) {
		random_shuffle(rd + 1, rd + n + 1);
		for(int i = 1; i <= n; i++) {
			if(work(rd[i]) == ((i - 1) % k)) continue;
			//	cout << "!";
			for(int j = 1; j < i; j++) if(check(rd[i], rd[j])) {
					if(rd[i] > rd[j]) swap(rd[i], rd[j]);
					cout << rd[i] << " " << rd[j] << "\n";
					return 0;
				}
		}
		memset(tmp, 0, sizeof(tmp));
		memset(tmd, 0, sizeof(tmd));
	}
	puts("-1 -1");
	return 0;
}
/*
5 2 3
1 1
1 1
1 1
1 1
1 1

*/
posted on 2019-05-20 22:00  fastle  阅读(144)  评论(0编辑  收藏  举报