#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 <int, 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++;
}
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
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:22:12: warning: unused variable 'j' [-Wunused-variable]
int i, j, id = -1;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
329 ms |
3040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
320 ms |
3024 KB |
Output is partially correct - 72.24% |