# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937565 | sleepntsheep | Utrka (COCI14_utrka) | C11 | 1 ms | 2648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<string.h>
#define N 100000
int o0[N],o1[N],n;
char s[2][N][21];
unsigned X=12345;
int rand_(){return(X*=3)>>1;}
int kk;
void sort(int*aa,int l,int r)
{
while(l<r)
{
int i=l,j=l,k=r,t,p=l+rand_()%(r-l),c;
while(j<k)
{
if(0 == (c=strcmp(s[kk][aa[j]],s[kk][aa[p]])))
++j;
else if (c < 0)
{
t=aa[j];
aa[j]=aa[i];
aa[i]=t;
++i;
++j;
}
else
{
t=aa[--k];
aa[k]=aa[j];
aa[j]=t;
}
}
sort(aa,l,i);
l=k;
}
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;++i) o0[i]=o1[i]=i, scanf("%s",s[0][i]);
for(int i=0;i<n-1;++i) scanf("%s",s[1][i]);
kk=0;sort(o0,0,n);
kk=1;sort(o1,0,n-1);
for (int l=0,i=0;i-1<n;++i,++l)
{
while (l + 1 < n - 1 && strcmp(s[0][o0[i]], s[1][o1[l]]) > 0) ++l;
if(i + 1 == n || strcmp(s[0][o0[i]],s[1][o1[l]]) < 0)
{
puts(s[0][o0[i]]);
return 0;
}
}
puts(s[0][n-1]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |