#pragma warning(disable:4996)
#include<stdio.h>
#define SZ 45001
#define INF 1000000000
int n, R[3][SZ + 10], D[3][SZ + 10], p1[3], p2[3];
int PP(int a, int M1, int b, int M2){
int i;
for (i = a; i <= INF + INF; i += M1){
if (i%M2 == b)break;
}
return i;
}
bool Correct(int a, int M1, int b, int M2){
if (a > b){ int t = a, a = b, b = t; }
if (a / M1 != b / M1){
if (p2[SZ - M1] != SZ * (a / M1) + (b / M1))return false;
}
else if (p2[SZ - M1])return false;
if (a / M2 != b / M2){
if (p2[SZ - M2] != SZ * (a / M2) + (b / M2))return false;
}
else if (p2[SZ - M2])return false;
return true;
}
void Do(int a, int b, int M1, int c, int d, int M2){
int i, d1, d2;
d1 = PP(a, M1, c, M2);
d2 = PP(b, M1, d, M2);
if (d1 > INF*2 || d2 > INF*2 || !Correct(d1, M1, d2, M2)){
d1 = PP(a, M1, d, M2);
d2 = PP(b, M1, c, M2);
}
if (d1 > d2)i = d1, d1 = d2, d2 = i;
printf("%d %d\n", d1 - INF, d2 - INF);
}
int main(){
int i, j, a, c, c2;
scanf("%d", &n);
for (j = 0; j != n; j++){
scanf("%d", &a);
a += INF;
for (i = 0; i < 3; i++){
R[i][a % (SZ - i)] = !R[i][a % (SZ - i)];
D[i][a / (SZ - i)] = !D[i][a / (SZ - i)];
}
}
for (i = 0; i < 3; i++){
c = 0, c2 = 0;
for (j = 0; j < SZ; j++){
if (R[i][j]){
c++;
if (p1[i]) p1[i] += j - 1;
else p1[i] = j * SZ + 1;
}
if (D[i][j]){
c2++;
if (p2[i]) p2[i] += j - 1;
else p2[i] = j * SZ + 1;
}
}
if ((c != 0 && c != 2) || (c2 != 0 && c2 != 2)){
while (1){
}
}
}
int k[6], c = 0;
for (i = 0; i < 3 && c < 6; i++){
if (p1[i])k[c++] = p1[i] / SZ, k[c++] = p1[i] % SZ, k[c++] = SZ - i;
}
Do(k[0], k[1], k[2], k[3], k[4], k[5]);
}
Compilation message
socks.cpp:1:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
socks.cpp: In function 'bool Correct(int, int, int, int)':
socks.cpp:14:25: warning: unused variable 'a' [-Wunused-variable]
socks.cpp:14:32: warning: unused variable 'b' [-Wunused-variable]
socks.cpp: In function 'int main()':
socks.cpp:66:12: error: redeclaration of 'int c'
socks.cpp:37:15: error: 'int c' previously declared here
socks.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
socks.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]