#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(strcmp(s[0][o0[i]],s[1][o1[l]]) < 0)
{
puts(s[0][o0[i]]);
return 0;
}
}
puts(s[0][n-1]);
}
Compilation message
utrka.c: In function 'main':
utrka.c:41:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
utrka.c:42:41: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | for(int i=0;i<n;++i) o0[i]=o1[i]=i, scanf("%s",s[0][i]);
| ^~~~~~~~~~~~~~~~~~~
utrka.c:43:28: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | for(int i=0;i<n-1;++i) scanf("%s",s[1][i]);
| ^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |