Submission #146351

#TimeUsernameProblemLanguageResultExecution timeMemory
146351popovicirobertLanguages (IOI10_languages)C++14
0 / 100
309 ms2960 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; #include "grader.h" #include "lang.h" #define SZ 100 const int B = (int) 1e9 + 7; int ok[60][66000], tot[60]; bool vis[60]; inline ll myrand() { return (1LL * rand() << 15) + rand(); } void excerpt(int *E) { int i, j, id = -1; unordered_map <int, int> mp; for(i = 0; i < 100; i++) { mp[E[i]]++; } vector < pair <ll, double> > arr(56); for(auto it : mp) { double coef = 1.0 * it.second / 100.0; for(i = 0; i < 56; i++) { if(ok[i][it.first]) { arr[i].first += 1LL * ok[i][it.first] * it.second; } arr[i].second += fabs(1.0 * ok[i][it.first] / tot[i] - coef); } } vector <int> ord(56); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](const int &x, const int &y) { if(arr[x].first == arr[y].first) return arr[x].second - arr[y].second > 0; return arr[x].first < arr[y].first; }); id = ord.back(); if(arr[id].first == 0) { id = -1; } if(id == -1) { vector <int> ids; for(i = 0; i < 56; i++) { if(vis[i] == 0) ids.push_back(i); } int sz = ids.size(); id = ids[myrand() % sz]; } id = language(id); for(i = 0; i < 100; i++) { ok[id][E[i]]++; } tot[id] += 100; vis[id] = 1; }

Compilation message (stderr)

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:22:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j, id = -1;
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...