Submission #222445

# Submission time Handle Problem Language Result Execution time Memory
222445 2020-04-13T07:27:36 Z rainy ACM (COCI19_acm) C++14
50 / 50
11 ms 384 KB
#include<bits/stdc++.h>
#define MAXN 1123
#define fr first
#define sc second
using namespace std;
typedef pair<int,int>ii;
typedef pair<ii,char*>atm;
int N,M;
char tn[MAXN][25];
char mt[25]="NijeZivotJedanACM";
char S,X;int HH,MM,SS;
int ts[MAXN];
int pt[MAXN];
int mi;
atm AT[MAXN];

int cmp(atm t1, atm t2){
    if(t1.fr.fr==t2.fr.fr&&t1.fr.sc==t2.fr.sc)return t1.sc<t2.sc;
    if(t1.fr.fr==t2.fr.fr)return t1.fr.sc<t2.fr.sc;
    return t2.fr.fr<t1.fr.fr;
}

int main(){
    scanf("%d%d",&N,&M);
    memset(ts,0,sizeof(ts));
    memset(pt,0,sizeof(pt));
    for(int i=0;i<N+1;i++){
        scanf(" %s",&tn[i]);
        //printf("tn[i]=[%s]\n",tn[i]);
        if(strcmp(tn[i],mt)==0&&i!=N){
            mi=i;
            char t='a';
            while(t!='\n'){
                scanf("%c",&t);
            }
        }
        else if(strcmp(tn[i],mt)){
            for(int j=0;j<M;j++){
                scanf(" %c",&S);
                assert(S=='+'||S=='-'||S=='?');
                if(S=='-'){
                    char t='a';
                    while(t!='\n'&&t!=' '){
                        scanf("%c",&t);
                    }
                    continue;
                    // pt[i]+=(t-'1')*20*60+HH*60*60+MM*60+SS;
                }
                ts[i]++;
                scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                pt[i]+=(X-1)*20*60+HH*60*60+MM*60+SS;
            }
        }
        else if(i==N){
            for(int j=0;j<M;j++){
                //printf("j=%d\n",j);
                scanf(" %c",&S);
                assert(S=='+'||S=='-'||S=='?');
                //printf("S=%c\n",S);
                if(S=='-'){
                    char t='a';
                    while(t!='\n'&&t!=' '){
                        scanf("%c",&t);
                    }
                    continue;
                    // pt[mi]+=(t-'0')*20*60+HH*60*60+MM*60+SS;
                }
                ts[mi]++;
                scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                pt[mi]+=(X-1)*20*60+HH*60*60+MM*60+SS;
            }
        }
    }
    for(int i=0;i<N;i++){
        AT[i]=make_pair(ii(ts[i],pt[i]),tn[i]);
    }
    sort(AT,AT+N,cmp);
    for(int i=0;i<N;i++){
        // printf("%s\t%d\t%d\n",AT[i].sc,AT[i].fr.fr,AT[i].fr.sc);
        if(strcmp(AT[i].sc,mt)==0){
            printf("%d\n",i+1);
            return 0;
        }
    }
    return 0;
}

Compilation message

acm.cpp: In function 'int main()':
acm.cpp:28:27: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[25]' [-Wformat=]
         scanf(" %s",&tn[i]);
                     ~~~~~~^
acm.cpp:50:51: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'char*' [-Wformat=]
                 scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                                     ~~            ^
acm.cpp:69:51: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'char*' [-Wformat=]
                 scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                                     ~~            ^
acm.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&M);
     ~~~~~^~~~~~~~~~~~~~
acm.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",&tn[i]);
         ~~~~~^~~~~~~~~~~~~~
acm.cpp:34:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%c",&t);
                 ~~~~~^~~~~~~~~
acm.cpp:39:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf(" %c",&S);
                 ~~~~~^~~~~~~~~~
acm.cpp:44:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                         scanf("%c",&t);
                         ~~~~~^~~~~~~~~
acm.cpp:50:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acm.cpp:57:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf(" %c",&S);
                 ~~~~~^~~~~~~~~~
acm.cpp:63:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                         scanf("%c",&t);
                         ~~~~~^~~~~~~~~
acm.cpp:69:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%d/%d:%d:%d",&X,&HH,&MM,&SS);
                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 11 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct