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
| #include<bits/stdc++.h> #define inf 0x3f3f3f3f3f3f3f3fll #define debug(x) cerr<<#x<<"="<<x<<endl using namespace std; using ll=long long; using ld=long double; using pli=pair<ll,int>; using pi=pair<int,int>; template<typename A> using vc=vector<A>; inline int read() { int s=0,w=1;char ch; while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1; while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } inline ll lread() { ll s=0,w=1;char ch; while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1; while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w; } mt19937 _rand(time(0)^clock()); const int L=10; int a[100005][105]; int id[100005]; int ss[105][105]; int sum[105]; int n,d,k; inline bool check(int u,int v) { int ans=0; for(int i=1;i<=d;i++) ans+=a[u][i]*a[v][i]; return !(ans%k); } inline void check(int i) { int p=id[i]; for(int j=1;j<i;j++) if(check(id[j],p)) { printf("%d %d\n",min(id[j],p),max(id[j],p)); return ; } assert(0); } inline bool check() { if(k==2) { memset(sum,0,sizeof(sum)); for(int i=1;i<=n;i++) { int p=id[i],v=0; for(int j=1;j<=d;j++) (v+=a[p][j]*sum[j])%=2,(sum[j]+=a[p][j])%=2; if(v!=(i-1)%2){ check(i);return true;} } return false; } else { memset(ss,0,sizeof(ss)); for(int i=1;i<=n;i++) { int p=id[i],v=0; for(int j=1;j<=d;j++) for(int k=1;k<=d;k++) { v+=ss[j][k]*a[p][j]*a[p][k]; ss[j][k]+=a[p][j]*a[p][k]; } if(v%3!=(i-1)%3){ check(i);return true;} } } return false; } int main() { n=read(),d=read(),k=read(); for(int i=1;i<=n;i++) { id[i]=i; for(int j=1;j<=d;j++) a[i][j]=read()%k; } for(int i=1;i<=L;i++) { shuffle(id+1,id+n+1,_rand); if(check()) return 0; } printf("-1\n"); return 0; }
|