Submission #959238

#TimeUsernameProblemLanguageResultExecution timeMemory
959238d4xnParrots (IOI11_parrots)C++17
97 / 100
7 ms1576 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; void encode(int n, int m[]) { pair<int, int> a[256]; int curr = 0; for (int i = 0; i < 64; i++) { a[curr++] = make_pair(i, -1); for (int j = 0; j < 3; j++) { a[curr++] = make_pair(i, j); } } for(int i = 0; i < n; i++) { vector<int> b(3, 0); for (int j = 0; j < 3; j++) { b[j] = m[i] % 8; m[i] /= 8; } int sum = b[0] + b[1] + b[2]; if (sum <= 18 - sum) { int y = 0; while (a[y].first != i || a[y].second != 0) y++; for (int j = 0; j < b[0]; j++) send(y); for (int j = 0; j < b[1]; j++) send(y+1); for (int j = 0; j < b[2]; j++) send(y+2); } else { int y = 0; while (a[y].first != i || a[y].second != -1) y++; send(y); for (int j = 0; j < 7-b[0]; j++) send(y+1); for (int j = 0; j < 7-b[1]; j++) send(y+2); for (int j = 0; j < 3-b[2]; j++) send(y+3); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int N, int L, int X[]) { pair<int, int> a[256]; int curr = 0; for (int i = 0; i < 64; i++) { a[curr++] = make_pair(i, -1); for (int j = 0; j < 3; j++) { a[curr++] = make_pair(i, j); } } int pw[3]; pw[0] = 1; for (int i = 1; i < 3; i++) { pw[i] = pw[i-1]*8; } vector<int> ans(N, 0), rev(N, 0); for (int i = 0; i < L; i++) { int x = X[i]; if (a[x].second == -1) { rev[a[x].first] = 1; ans[a[x].first] = pw[0]*7 + pw[1]*7 + pw[2]*3; } } for (int i = 0; i < L; i++) { int x = X[i]; if (a[x].second == -1) continue; ans[a[x].first] += (rev[a[x].first] ? -pw[a[x].second] : pw[a[x].second]); } for (int i = 0; i < N; i++) { output(ans[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...