80PTS WA8/10
查看原帖
80PTS WA8/10
290606
奇犽楼主2022/8/3 15:50
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

const int M=500003;
string lsh[M],a[M],b[M];
int n=1,m;
int c[M],d[M];
int le,ri,mid;

int fin(string s){
	//cout<<s<<endl;
	le=1;
	ri=m;
	//printf("%d %d %d\n",le,mid,ri);
	while(le<ri){
		mid=(le+ri)/2;
		//printf("%d %d %d\n",le,mid,ri);
		if(s<=lsh[mid]){
			ri=mid;
		}
		else{
			le=mid+1;
		}
	}
	//printf("\n------\n");
	return ri;
}

int main(){
	while(cin>>a[n]>>b[n]){
		lsh[n*2-1]=a[n];
		lsh[n*2]=b[n];
		n++;
	}
	n--;
	sort(lsh+1,lsh+1+n+n);
	
	int tot=0,jd=0;
	for(int i=1;i<=n+n+1;i++){
		if(lsh[i]==lsh[i-1]){
			tot++;
		}
		else{
			if(tot%2==1)jd++;
			tot=1;
		}
	}
	
	if(jd==2||jd==0){
		printf("Possible");
	}
	else{
		printf("Impossible");
	}
}
2022/8/3 15:50
加载中...