Submission #351256

#TimeUsernameProblemLanguageResultExecution timeMemory
351256idk321Parrots (IOI11_parrots)C++11
81 / 100
8 ms1540 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; void encode(int n, int m[]) { vector<int> sm(m, m + n); sort(sm.begin(), sm.end()); bool vis[n] = {}; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) send(m[i]); } int add = 0; int times = 1; for (int i = 0; i < n; i++) { if (add > 255) { add = 0; times++; } int curr = sm[i]; int ind = -1; for (int j = 0; j < n; j++) { if (!vis[j] && curr == m[j]) { ind = j; vis[j] = true; break; } } for (int j = 0; j < times; j++ )send(add + ind); add += 32; } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int n, int l, int x[]) { vector<int> freq(256); vector<int> res(n, -1); for (int i = 0; i < l; i++) { freq[x[i]]++; } vector<int> v; vector<int> ind; for (int i = 0; i < 256; i++) { for (int j = 0; j < freq[i] / 5; j++)v.push_back(i); freq[i] %= 5; } for (int j = 1; j <= 4; j++) { for (int i = 0; i < 256; i++)if (freq[i] == j) ind.push_back(i % 32); } for (int i = 0; i < n; i++) { //cout << ind[i] << endl; res[ind[i]] = v[i]; } for (int i : res) output(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...