제출 #959239

#제출 시각아이디문제언어결과실행 시간메모리
959239d4xn앵무새 (IOI11_parrots)C++17
95 / 100
8 ms1804 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] % 9; m[i] /= 9; } int sum = b[0] + b[1] + b[2]; if (sum <= 20 - 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 < 8-b[0]; j++) send(y+1); for (int j = 0; j < 8-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]*9; } 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]*8 + pw[1]*8 + 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...