제출 #1188132

#제출 시각아이디문제언어결과실행 시간메모리
1188132Sofiatpc앵무새 (IOI11_parrots)C++20
98 / 100
6 ms840 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; #define fi first #define sc second #define sz(v) (int)v.size() int ativo(int x, int p){ if(x & (1<<p))return 1; return 0; } void encode(int n, int m[]) { map<int,int> freq, v; for(int p = 0; p < 8; p++){ for(int i = 0; i < n; i+=2){ int x = (ativo(m[i], p)<<1); if(i+1 < n)x += ativo(m[i+1], p); freq[x]++; } } vector< pair<int,int> > o; for(int i = 0; i < 4; i++)o.emplace_back(freq[i], i); sort(o.begin(),o.end(),greater<pair<int,int>>()); for(int i = 0; i < sz(o); i++) v[o[i].sc] = i; for(int p = 0; p < 8; p++){ int g = 0; for(int i = 0; i < n; i+=2){ int x = (ativo(m[i], p)<<1); if(i+1 < n)x += ativo(m[i+1], p); int val = (p<<5) + g; for(int j = 0; j < v[x]; j++)send(val); g++; } } vector<int> a = {0,1,2,3}; int ans = 0; do{ int parar = 1; for(int i = 0; i < 4; i++) if(a[i] != o[i].sc){parar = 0; break;} if(parar){ for(int i = 0; i < 4; i++)send(ans); break; } ans++; }while(next_permutation(a.begin(),a.end())); }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; static int v[70]; static map<int,int> freq; #define fi first #define sc second void decode(int n, int l, int x[]) { for(int i = 0; i < n; i++)v[i] = 0; freq.clear(); for(int p = 0; p < 8; p++) for(int g = 0; g*2 < n; g++)freq[(p<<5)+g] = 0; for(int i = 0; i < l; i++)freq[x[i]]++; int qtd = 0; auto it = freq.begin(); while(it != freq.end()){ if(it->sc >= 4){ qtd = it->fi; freq[it->fi] -= 4; break; } it++; } vector<int> a = {0,1,2,3}; int cur = 0; do{ if(cur == qtd)break; cur++; }while(next_permutation(a.begin(),a.end())); for(auto it : freq){ int x = it.fi, f = a[it.sc]; int g = x%32; x/=32; int p = x; if(f & 2)v[g*2] += (1<<p); if(f & 1)v[g*2+1] += (1<<p); } for(int i = 0; i < n; i++)output(v[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...