Submission #8075

#TimeUsernameProblemLanguageResultExecution timeMemory
8075ho94949Languages (IOI10_languages)C++98
37 / 100
7250 ms3504 KiB
#include <stdlib.h> #include <stdio.h> #include <map> using namespace std; #include "grader.h" #include "lang.h" #define SZ 100 #define LANG 56 map<unsigned int, int> A[LANG]; int appear[LANG]; void excerpt(int *E) { double langcnt[LANG]; for(int i=0;i<LANG;i++) langcnt[i]=0; for(int i=0;i<SZ-1;i++){ unsigned int triplet=E[i+1]<<16+E[i+2]; for(int j=0;j<LANG;j++){ map<unsigned int,int>::iterator it=A[j].find(triplet); if(it!=A[j].end()) langcnt[j]+=(double)(*it).second/(appear[LANG]+1); } } double max=0; int maxi=0; for(int i=0;i<LANG;i++){ if(max<langcnt[i]){ max=langcnt[i]; maxi=i; } } int res=language(maxi); appear[res]++; for(int i=0;i<SZ-1;i++){ unsigned int triplet=E[i+1]<<16+E[i+2]; A[res][triplet]=A[res][triplet]+1; } return; }

Compilation message (stderr)

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:20:34: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   unsigned int triplet=E[i+1]<<16+E[i+2];
                                ~~^~~~~~~
lang.cpp:38:34: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   unsigned int triplet=E[i+1]<<16+E[i+2];
                                ~~^~~~~~~
lang.cpp:24:50: warning: array subscript is above array bounds [-Warray-bounds]
     langcnt[j]+=(double)(*it).second/(appear[LANG]+1);
                                       ~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...