Title Description For example, there is a n*m table, and each lattice has a number. We define the rectangle that the primary rectangle determines for the given pair of coordinates (which is always a pair of vertex coordinates of a rectangle). It produces up to 4 sub-rectangles, which are determined by the vertices and table boundaries of the main rectangle. What we need is the XOR value of the number of all the shaded parts. X1=3,y1=3,x2=4,y2=4, so the answer is A11^A12^A21^A22^A15^A16^A25^A26^A33^A34^A43^A44^A51^A52^A61^A62^A55^A56^A65^A66. Where ' ^ ' represents the XOR symbol, AIJ represents the number in the square of row I, column J. InputThe first line is an integer T (t≤10) that represents the number of test data groups. The first row of each group of data three integer n,m,q (0<n,m≤1000,q≤500000), q indicates that there is a Q group to ask. Then enter n rows, each with m digits, indicating the number in the table (non-negative integer, not greater than 109). Finally there is Q line, which indicates Q query, each line contains 4 positive integers x1,y1,x2,y2 (1≤x1≤x2≤n,1≤y1≤y2≤m). OutputFor each query, output a line that represents an XOR or result. Sample input14 4 31 0 2 10 2 1 12 1 1 01 1 0 22 2 2 22 2 3 32 2 4 4 Sample output000 TipsA large number of input and output, please use C-style input and output; 1=2^3^4^ Whole; #include <iostream>#include<stdio.h>#include<string.h>#include<algorithm>#defineN 1050using namespacestd;intMaps[n][n],a[n][n];intMain () {intn,t,m,k,i,j,a,b,c,d,e; intX,y,x0,y0,x1,y1,x2,y2; scanf ("%d",&T); while(t--) {memset (A,0,sizeof(a)); memset (Maps,0,sizeof(maps)); scanf ("%d%d%d",&n,&m,&k); for(i=1; i<=n;i++) { for(j=1; j<=m;j++) {scanf ("%d",&Maps[i][j]); A[I][J]=a[i-1][j]^a[i][j-1]^a[i-1][j-1]^Maps[i][j]; } } for(i=0; i<k;i++) {scanf ("%d %d%d%d",&x,&y,&x0,&y0); X1=min (x,x0); Y1=min (y,y0); X2=Max (x,x0); Y2=Max (Y,Y0); A=a[x1-1][y1-1]; B=a[x1-1][m]^a[x1-1][y2]; C=a[n][y1-1]^a[x2][y1-1]; D=a[n][m]^a[x2][m]^a[n][y2]^A[x2][y2]; E=a[x2][y2]^a[x1-1][y2]^a[x2][y1-1]^a[x1-1][y1-1]; printf ("%d\n", a^b^c^d^d); } } return 0;} |