제출 #1240138

#제출 시각아이디문제언어결과실행 시간메모리
1240138countless앵무새 (IOI11_parrots)C++20
98 / 100
13 ms840 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define sp <<" "<< #define endl "\n" void encode(int N, int M[]) { for (int i = 0; i < N; i++) { cerr << M[i] << " "; } cerr << endl; vector<int> one, zero; for (int i = 0; i < N; i++) { for (int j = 0; j < 8; j+=2) { int rep = 0; if (M[i] & (1 << j)) { rep |= (1 << 0); } if (M[i] & (1 << (j+1))) { rep |= (1 << 1); } int oth = 3 - rep; while (rep--) { one.push_back((i * 8 + j) / 2); } while (oth--) { zero.push_back((i * 8 + j) / 2); } } } if (one.size() < zero.size()) { for (auto &x : one) { send(x); } } else { for (auto &x : zero) { send(x); } for (int i = 0; i < 4; i++) { send(255); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define sp <<" "<< #define endl "\n" void decode(int N, int L, int X[]) { vector<int> cnt(256); for (int i = 0; i < L; i++) { cnt[X[i]]++; } bool flip = false; if (cnt[255] >= 4) { cnt[255] -= 4; flip = true; } vector<int> M(N, 0); for (int i = 0; i < 256; i++) { int j = i * 2; int pos = j / 8, bit = j % 8; if (cnt[i] & (1 << 0)) { M[pos] |= (1 << bit); } if (cnt[i] & (1 << 1)) { M[pos] |= (1 << (bit+1)); } } if (flip) { for (int i = 0; i < N; i++) { for (int j = 0; j < 8; j++) { M[i] ^= (1 << j); } } } for (int i = 0; i < N; i++) { cerr << M[i] << " "; } cerr << endl; for (auto &x : M) { output(x); } }
#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...