求解 我怎么只有50分
查看原帖
求解 我怎么只有50分
292123
AKiloNewbility楼主2022/6/27 21:48
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long long a[10000005];
long long n,i,j;
string str;
int main(){
	scanf("%lld\n",&n);
	for(int t=0;t<n;t++){
		cin>>str;
		for(int k=0;k<str.length();k++){
			char temp=str[k];
			if(temp=='A'||temp=='B'||temp=='C'||temp=='2'){//2
				a[t]=a[t]*10+2;
			}else if(temp=='D'||temp=='E'||temp=='F'||temp=='3'){//3
				a[t]=a[t]*10+3;
			}else if(temp=='G'||temp=='H'||temp=='I'||temp=='4'){//4
				a[t]=a[t]*10+4;
			}else if(temp=='t'||temp=='K'||temp=='L'||temp=='5'){//5
				a[t]=a[t]*10+5;
			}else if(temp=='M'||temp=='N'||temp=='O'||temp=='6'){;//6
				a[t]=a[t]*10+6;
			}else if(temp=='P'||temp=='R'||temp=='S'||temp=='7'){//7
				a[t]=a[t]*10+7;
			}else if(temp=='T'||temp=='U'||temp=='V'||temp=='8'){//8
				a[t]=a[t]*10+8;
			}else if(temp=='W'||temp=='X'||temp=='Y'||temp=='9'){//9
				a[t]=a[t]*10+9;
			}else if(temp=='-'){
				continue;
			}else if(temp=='0'){
				a[t]=a[t]*10;
			}else if(temp=='1'){
				a[t]=a[t]*10+1;
			}
		}
	}
	sort(a,a+n);
	long long sum=1;
	bool flag=false;
	for(i=0;i<n;i++){
		if(a[i]!=a[i+1]){
			if(sum>1){
				printf("%03lld-%04lld %lld\n",a[i]/10000%1000,a[i]%10000,sum);
				flag=true;	
				sum=1;

			}		
		}else{
			sum++;
		}
	}
	if(!flag){
		printf("No duplicates.\n");
	}
	return 0;
}

2022/6/27 21:48
加载中...