제출 #250690

#제출 시각아이디문제언어결과실행 시간메모리
250690kostia244앵무새 (IOI11_parrots)C++17
34 / 100
3 ms1536 KiB
#include "encoder.h" #include "encoderlib.h" #include<bits/stdc++.h> using namespace std; namespace aaa { const int C = 7, A = 3; vector<vector<int>> s; vector<int> cur; void gen(int lst = 0) { cur.push_back(lst); s.push_back(cur); if(cur.size() < C) { gen(lst); } cur.pop_back(); if(lst+1 < A) gen(lst+1); } void init() { if(s.size()) return; gen(0); sort(s.begin(), s.end(), [](auto a, auto b) { return a.size() < b.size(); }); } void sendk(int P, int k) { //cout << P << " -> " << k << '\n'; for(auto i : s[k]) send(P*4 + i);//, cout << P*4+i << '\n'; } }; void encode(int n, int b[]) { using namespace aaa; init(); vector<array<int, 2>> a; for(int i = 0; i < n; i++) send(4*b[i] + 3); for(int i = 0; i < n; i++) a.push_back({b[i], i}); sort(a.begin(), a.end()); for(int i = 0; i < n; i++) { sendk(a[i][1], i); } }
#include "decoder.h" #include "decoderlib.h" #include<bits/stdc++.h> using namespace std; vector<int> st[256]; namespace aab { const int C = 7, A = 3; vector<vector<int>> s; vector<int> cur; void gen(int lst = 0) { cur.push_back(lst); s.push_back(cur); if(cur.size() < C) { gen(lst); } cur.pop_back(); if(lst+1 < A) gen(lst+1); } void init() { for(auto &i : st) i.clear(); if(s.size()) return; gen(0); sort(s.begin(), s.end(), [](auto a, auto b) { return a.size() < b.size(); }); } int id(int P) { int x = 0; //cout << P << " : "; //for(auto i : st[P]) cout << i << " "; cout << endl; while(x < 69 && st[P] != s[x]) x++; //cout << x << '\n'; return x < 69 ? x : 0; } }; void decode(int n, int l, int X[]) { using namespace aab; init(); vector<int> res(n), vals; //cout << l << " ?????\n"; for(int i = 0; i < l; i++) { //cout << i << " // " << X[i]/4 << endl; //if((X[i]&3) == 3) cout << X[i] << endl; st[X[i]/4].push_back(X[i]&3); } for(int i = 0; i < 256; i++) { for(int j = st[i].size(); j--;) if(st[i][j] == 3) { swap(st[i][j], st[i].back()); st[i].pop_back(); vals.push_back(i); //cout << i << "Here\n"; } //if(i < n) //cout << i << " " << id(i) << " " << st[i].size() << endl; sort(st[i].begin(), st[i].end()); } for(int i = 0; i < n; i++) output(vals[id(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...