제출 #518498

#제출 시각아이디문제언어결과실행 시간메모리
518498tabr앵무새 (IOI11_parrots)C++17
0 / 100
2092 ms173200 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif #define encoder #ifdef tabr int dat[100]; int id = 0; void send(int x) { dat[id++] = x; } void output(int x) { cout << x << '\n'; } #else #include "decoder.h" #include "decoderlib.h" #include "encoder.h" #include "encoderlib.h" #endif #ifdef encoder void encode(int n, int a[]) { vector<vector<int>> w(4); for (int i = 0; i < (1 << 27); i++) { int c = __builtin_popcount(i); if (c % 5 == 0 && c <= 15) { w[c / 5].emplace_back(i); } } for (int beg = 0; beg < n; beg += 3) { int c = min(3, n - beg); int z = 0; for (int i = beg; i < min(n, beg + 3); i++) { z *= 256; z += a[i]; } int k = w[c][z]; vector<int> b; int lst = 0; for (int i = 0; i < c * 5 + 12; i++) { if (k & (1 << i)) { b.emplace_back(lst); } else { lst++; } } for (int i : b) { send(i + beg * 4); } debug(c); debug(z); debug(k); debug(b); } } #endif #ifdef decoder void decode(int n, int l, int a[]) { vector<vector<int>> w(4); for (int i = 0; i < (1 << 27); i++) { int c = __builtin_popcount(i); if (c % 5 == 0 && c <= 15) { w[c / 5].emplace_back(i); } } sort(a, a + l); for (int beg = 0; beg < n; beg += 3) { int c = min(3, n - beg); vector<int> b; for (int i = beg * 5; i < min(n, beg + 3) * 5; i++) { b.emplace_back(a[i] - beg * 4); } int k = 0; for (int i = 0; i < (int) b.size(); i++) { k |= 1 << (i + b[i]); } int z = (int) (lower_bound(w[c].begin(), w[c].end(), k) - w[c].begin()); debug(c); debug(b); debug(k); debug(z); b.clear(); for (int i = 0; i < c; i++) { b.emplace_back(z % 256); z /= 256; } reverse(b.begin(), b.end()); for (int i : b) { output(i); } } } #endif #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); int n = 6; int a[] = {1, 1, 4, 5, 1, 4}; encode(n, a); decode(n, id, dat); return 0; } #endif
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif #define decoder #ifdef tabr int dat[100]; int id = 0; void send(int x) { dat[id++] = x; } void output(int x) { cout << x << '\n'; } #else #include "decoder.h" #include "decoderlib.h" #include "encoder.h" #include "encoderlib.h" #endif #ifdef encoder void encode(int n, int a[]) { vector<vector<int>> w(4); for (int i = 0; i < (1 << 27); i++) { int c = __builtin_popcount(i); if (c % 5 == 0 && c <= 15) { w[c / 5].emplace_back(i); } } for (int beg = 0; beg < n; beg += 3) { int c = min(3, n - beg); int z = 0; for (int i = beg; i < min(n, beg + 3); i++) { z *= 256; z += a[i]; } int k = w[c][z]; vector<int> b; int lst = 0; for (int i = 0; i < c * 5 + 12; i++) { if (k & (1 << i)) { b.emplace_back(lst); } else { lst++; } } for (int i : b) { send(i + beg * 4); } debug(c); debug(z); debug(k); debug(b); } } #endif #ifdef decoder void decode(int n, int l, int a[]) { vector<vector<int>> w(4); for (int i = 0; i < (1 << 27); i++) { int c = __builtin_popcount(i); if (c % 5 == 0 && c <= 15) { w[c / 5].emplace_back(i); } } sort(a, a + l); for (int beg = 0; beg < n; beg += 3) { int c = min(3, n - beg); vector<int> b; for (int i = beg * 5; i < min(n, beg + 3) * 5; i++) { b.emplace_back(a[i] - beg * 4); } int k = 0; for (int i = 0; i < (int) b.size(); i++) { k |= 1 << (i + b[i]); } int z = (int) (lower_bound(w[c].begin(), w[c].end(), k) - w[c].begin()); debug(c); debug(b); debug(k); debug(z); b.clear(); for (int i = 0; i < c; i++) { b.emplace_back(z % 256); z /= 256; } reverse(b.begin(), b.end()); for (int i : b) { output(i); } } } #endif #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); int n = 6; int a[] = {1, 1, 4, 5, 1, 4}; encode(n, a); decode(n, id, dat); return 0; } #endif
#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...