Submission #146353

# Submission time Handle Problem Language Result Execution time Memory
146353 2019-08-23T14:57:39 Z popovicirobert Languages (IOI10_languages) C++14
60 / 100
328 ms 3064 KB
#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, ll> > arr(56);
    for(auto it : mp) {
        for(i = 0; i < 56; i++) {
            if(ok[i][it.first]) {
                arr[i].first++;
            }
            arr[i].second += ok[i][it.first];
        }
    }

    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;
            ^
# Verdict Execution time Memory Grader output
1 Correct 279 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 328 ms 2988 KB Output is partially correct - 56.27%