算法競(jìng)賽2021 ICPC Southeastern Europe Regional Contest_King of Strin
2022-03-14 14:45 作者:Clayton_Zhou | 我要投稿
//#include "stdafx.h"
#include<cstdio>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int n=7;
?char s[211000]="trivial";
?char t[211000]="problem";
int main(){??
? scanf("%d",&n);?
scanf("%s",s);scanf("%s",t);
/*
int i;
for (i=0;i<n;i++)
{
char ch;
ch=getchar();
if(ch!=10 && ch!=13)s[i]=ch;
else i--;
}
for ( i=0;i<n;i++)
{
char ch;
ch=getchar();
if(ch!=10 && ch!=13)t[i]=ch;
else i--;
}*/
?
long? ?long sum=0;?
int si=n-1;
int flag=0;
? ?
while( si? !=-1)??
{
if(? ?*(s+si )<= *(t+ si ))
{
if(*(s+si)< *(t+si)){
flag=si;
sum+=n-si;
//printf("in %d,? %s,? k=%d\n",n-si, s+si,si);
}
else if( flag? )sum+=n-flag;
}
else flag=0;
?
si--; ?
}
printf("%lld\n",sum);?
return 0;
}
標(biāo)簽: