Submission #937578

# Submission time Handle Problem Language Result Execution time Memory
937578 2024-03-04T09:07:10 Z sleepntsheep Utrka (COCI14_utrka) C
80 / 80
70 ms 5208 KB
#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=aa[l+rand_()%(r-l)],c;
        while(j<k) {
            if(0 == (c=strcmp(s[kk][aa[j]],s[kk][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)
    {
        if(strcmp(s[0][o0[i]],s[1][o1[i]]))
        {
            puts(s[0][o0[i]]);
            return 0;
        }
    }
    puts(s[0][o0[n-1]]);
}

Compilation message

utrka.c: In function 'main':
utrka.c:38:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d",&n);
      |     ^~~~~~~~~~~~~~
utrka.c:39:41: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     for(int i=0;i<n;++i) o0[i]=o1[i]=i, scanf("%s",s[0][i]);
      |                                         ^~~~~~~~~~~~~~~~~~~
utrka.c:40:28: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     for(int i=0;i<n-1;++i) scanf("%s",s[1][i]);
      |                            ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 34 ms 3676 KB Output is correct
7 Correct 52 ms 4600 KB Output is correct
8 Correct 65 ms 4956 KB Output is correct
9 Correct 70 ms 5208 KB Output is correct
10 Correct 70 ms 5168 KB Output is correct