解题思路:排序后遍历,如果两个数直接相同即为重号,如果两个数之间的值大于等于2即为断号。PS:难点在于如何输入。
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
namespace IO{
inline LL read(){
LL o=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){o=o*10+c-'0';c=getchar();}
return o*f;
}
}using namespace IO;
const int N=1e5+7,M=1e4+7,INF=0x3f3f3f3f,mod=1e9+7,P=131;
int a[N],n;
int main(){
int cnt;
cin>>cnt;
string line;
getline(cin,line);
while(cnt--){
getline(cin,line);
stringstream ssin(line);
while(ssin>>a[n])n++;
}
sort(a,a+n);
int res1,res2;
for(int i=0;i<n-1;i++){
if(a[i]==a[i+1])res1=a[i];
if(a[i]+2<=a[i+1])res2=a[i]+1;
}
cout<<res2<<" "<<res1<<endl;
return 0;
}