Submission #935206

#TimeUsernameProblemLanguageResultExecution timeMemory
935206KebabuVaikis15Parrots (IOI11_parrots)C++17
0 / 100
6 ms2344 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; static map<int, bool> lank; static map<int, pair<int, int>> perm; static int b[7]; static int iSkaiciu() { int s=0; for (int i=0; i<7; i++) s+=b[i]<<(2*i); return s; } static void pildyti(int L) { int val=iSkaiciu(); if (lank.count(val)) return; lank[val]=1; perm[perm.size()]={L, val}; for (int i=0; i<L; i++) if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1])) { b[i]++; pildyti(L); b[i]--; } } void encode(int N, int M[]) { for (int i=0; i<=7; i++) { pildyti(i); lank.clear(); } for (int i=0; i<N; i++) for (int j=0; j<perm[M[i]].first; j++) { send((i<<2)+((perm[M[i]].second>>(2*j))&3)); // cout<<((i<<2)+((perm[M[i]].second>>(2*j))&3))<<endl; } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; static map<int, bool> lank2; static map<pair<int, int>, int> perm2; static int b[7]; static int iSkaiciu2() { int s=0; for (int i=0; i<7; i++) s+=b[i]<<(2*i); return s; } static void pildyti2(int L) { int val=iSkaiciu2(); if (lank2.count(val)) return; lank2[val]=1; perm2[{L, val}]=perm2.size(); for (int i=0; i<L; i++) if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1])) { b[i]++; pildyti2(L); b[i]--; } } void decode(int N, int L, int X[]) { vector<int> B[N]; for (int i=0; i<=7; i++) { pildyti2(i); lank2.clear(); } for (int i=0; i<L; i++) B[X[i]>>2].push_back(X[i]&3); for (int i=0; i<N; i++) { sort(B[i].begin(), B[i].end()); int s=0; for (long unsigned int j=0; j<B[i].size(); j++) s+=B[i][j]<<(2*j); output(perm2[{B[i].size(), s}]); } }
#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...