Submission #349989

#TimeUsernameProblemLanguageResultExecution timeMemory
349989idk321Parrots (IOI11_parrots)C++11
52 / 100
3 ms1340 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++) { send(m[i]); send(m[i]); } int add = 0; for (int i = 0; i < n - 1; i++) { 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; } } send(add + ind); add += 16; } }
#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] / 2; j++)v.push_back(i); if (freq[i] % 2 == 1) ind.push_back(i % 16); } sort(v.begin(), v.end()); for (int i = 0; i < n - 1; i++) { //cout << ind[i] << endl; res[ind[i]] = v[i]; } for (int i = 0; i < n; i++) { if (res[i] == -1) res[i] = v[n - 1]; } 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...