답안 #937577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937577 2024-03-04T09:06:37 Z sleepntsheep 마라톤 경주 (COCI14_utrka) C
0 / 80
56 ms 65536 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][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)
    {
        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]);
      |                            ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 56 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -