1 solutions
-
0
C++ :
#include <cstdio> #include <cstring> #include <algorithm> using namespace std ; const int MAXN = 20000 + 10 ; int data[MAXN] ; int emp[MAXN] ; char str[MAXN*10] ; int n = 0 ; void init() { n = 0 ; int tmp = 0 ; bool has = false ; for( int i = 0 ; str[i] != '\0' ; i ++ ) { if( str[i] >= '0' && str[i] <= '9' ) { tmp = tmp * 10 + str[i] - '0' ; has = true ; } else if( has ) { data[n++] = tmp ; tmp = 0 ; has = false ; } } if( has ) data[n++] = tmp ; } int main() { char c ; while( gets(str) ) { init() ; // sort( data , data + n ) ; for( int i = 1 ; i < n ; i ++ ) emp[i] = data[i] - data[i-1] - 1 ; int jud = 0 ; for( int i = 1 ; i < n ; i += 2 ) jud ^= emp[i] ; if( jud == 0 ) printf("-1\n") ; else { int pos1 , pos2 ; for( int i = 1 ; i < n ; i += 2 ) { if( ( emp[i] ^ jud ) < emp[i] ) { pos1 = data[i-1] ; pos2 = pos1 + ( emp[i] - ( emp[i] ^ jud ) ) ; break ; } else if( ( emp[i] ^ jud ) < emp[i] + emp[i+1] ) { pos1 = data[i] ; pos2 = pos1 + ( ( emp[i] ^ jud ) - emp[i] ) ; break ; } } printf("%d %d\n" , pos1 , pos2 ) ; } } return 0 ; }
- 1
Information
- ID
- 16309
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By