Submission #414669

#TimeUsernameProblemLanguageResultExecution timeMemory
414669jeqchoParrots (IOI11_parrots)C++17
98 / 100
10 ms1328 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second // subtask 5: 7 points void encode(int N, int M[]) { vector<bool> mes(8*N); F0R(i,N) { F0R(j,8) { if(M[i]&(1<<j)) { mes[i*8+j]=1; } } } vi scheme[2]; F0R(i,4*N) { bool f = mes[2*i]; bool s = mes[2*i+1]; int state=0; if(!f && !s) { state=0; } else if(f && !s) { state=1; } else if(!f && s) { state =2; } else { state=3; } F0R(j,state) { scheme[0].pb(i); } F0R(j,3-state) { scheme[1].pb(i); } } if(sz(scheme[0])<sz(scheme[1])) { trav(e,scheme[0]) { send(e); } } else { trav(e,scheme[1]) { send(e); } F0R(i,4) { send(0); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second // subtask 5: 7 points pair<bool,bool> d(int state, bool scheme) { bool f,s; if(state==0) { f=0; s=0; } else if(state==1) { f=1; s=0; } else if(state==2) { f=0; s=1; } else { f=1; s=1; } if(scheme) { f=!f; s=!s; } return {f,s}; } void decode(int N, int L, int X[]) { vi state(4*N); F0R(i,L) { int pos = X[i]; ++state[pos]; } bool scheme=0; if(state[0]>=4) { state[0]-=4; scheme=1; } vector<bool> mes(8*N); F0R(i,4*N) { bool f,s; tie(f,s) = d(state[i],scheme); mes[2*i]=f; mes[2*i+1]=s; } vi ans(N); F0R(i,N) { ans[i] = 0; F0R(j,8) { ans[i] += mes[8*i+j]<<j; } output(ans[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...