Submission #60834

#TimeUsernameProblemLanguageResultExecution timeMemory
60834spencercomptonLanguages (IOI10_languages)C++17
74 / 100
1472 ms14732 KiB
#include <stdlib.h> #include <stdio.h> #include <bits/stdc++.h> #include "grader.h" #include "lang.h" using namespace std; #define SZ 100 int freq[56][65536]; double allsq[56]; int tot[56]; bool f = true; void excerpt(int *E) { // cout << "A " << endl; if(f){ for(int i = 0; i<65536; i++){ for(int j = 0; j<56; j++){ freq[j][i] = 0; tot[j] = 0; allsq[j] = 0.0; } } f = false; } pair<double, int> best = make_pair(655360.0,0); vector<int> li2; for(int i = 0; i<100; i++){ li2.push_back(E[i]); } sort(li2.begin(),li2.end()); vector<pair<int, double> > li; for(int i = 0; i<100; i++){ if(i==0 || li2[i]!=li2[i-1]){ int cnt = 0; for(int j = i; j<100 && li2[i]==li2[j]; j++){ cnt++; } li.push_back(make_pair(li2[i],cnt)); } } // cout << "B " << endl; for(int i = 0; i<56; i++){ if(tot[i]==0){ continue; } double now = allsq[i]; for(int j = 0; j<li.size(); j++){ int ch = li[j].first; double f1 = (double)freq[i][ch]/(double)tot[i]; double f2 = (double)li[j].second / 100.0; now -= f1 * f1; now += (f1-f2) * (f1-f2); } best = min(best,make_pair(now,i)); } // cout << "C " << endl; int res = language(best.second); for(int i = 0; i<100; i++){ freq[res][E[i]]++; tot[res]++; } // cout << "D" << endl; allsq[res]=0.0; for(int i = 0; i<65536; i++){ double ff = (double)(freq[res][i])/(double)tot[res]; allsq[res] += ff*ff; } // cout << "E " << endl; }

Compilation message (stderr)

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j<li.size(); j++){
                  ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...