답안 #146348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146348 2019-08-23T14:51:21 Z popovicirobert Languages (IOI10_languages) C++14
59 / 100
296 ms 2952 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 += 1LL * ok[i][it.first] * it.second;
        }
    }

    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;
                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 296 ms 2912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 279 ms 2952 KB Output is partially correct - 55.68%