Submission #358530

# Submission time Handle Problem Language Result Execution time Memory
358530 2021-01-25T17:06:47 Z idk321 Languages (IOI10_languages) C++
0 / 100
10000 ms 4568 KB
#include <stdlib.h>
#include <stdio.h>

#include "grader.h"
#include "lang.h"

#define SZ 100

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

unordered_map<int, ll> freq [56];
bool vis[56];

void excerpt(int *E) {
    unordered_map<int, ll> cfreq;
   for (int i = 0; i < 100; i++)
   {
        cfreq[E[i]]++;
   }

   ll best = -1;
   ll bscore = -1;
   ll factor = 1000000000;
   for (int i = 0; i < 56; i++)
   {
        ll score = 0;
        for (auto it = freq[i].begin(); it != freq[i].end(); it++)
        {
            if (it->second != 0 && cfreq[it->first] != 0)
            {
                 score += factor;
                 score -= abs(it->second - cfreq[it->first]) * (factor) / 10;
            }
        }
        if (score >  bscore)
        {
            best = i;
            bscore = score;
        }
   }

   int actual = language(best);

   if (!vis[actual])
   {
        vis[actual] = true;
        freq[actual] = cfreq;
   } else
   {
        unordered_set<int> s;
        for (auto it = freq[actual].begin(); it != freq[actual].end(); it++)
        {
            s.insert(it->first);
        }
        for (auto it = cfreq.begin(); it != cfreq.end(); it++)
        {
            s.insert(it->first);
        }

        unordered_map<int, ll> nfreq;
        for (int num : s) nfreq[num] = (freq[actual][num] + cfreq[num]) / 2;
        freq[actual] = nfreq;
   }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10096 ms 4372 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10100 ms 4568 KB Time limit exceeded