제출 #1113119

#제출 시각아이디문제언어결과실행 시간메모리
1113119julia_08앵무새 (IOI11_parrots)C++17
98 / 100
8 ms1684 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; void solve(int k, int i, bool zero){ vector<int> bit(8, 0); for(int i=0; i<8; i++){ if(k & (1 << i)){ bit[i] = 1; } } vector<int> pair; if(zero){ // mando quando ta desligado for(int j=0; j<8; j+=2){ if(!bit[j] && !bit[j + 1]) pair.push_back(3); if(bit[j] && !bit[j + 1]) pair.push_back(2); if(!bit[j] && bit[j + 1]) pair.push_back(1); if(bit[j] && bit[j + 1]) pair.push_back(0); } } else{ for(int j=0; j<8; j+=2){ if(!bit[j] && !bit[j + 1]) pair.push_back(0); if(bit[j] && !bit[j + 1]) pair.push_back(1); if(!bit[j] && bit[j + 1]) pair.push_back(2); if(bit[j] && bit[j + 1]) pair.push_back(3); } } for(int j=0; j<pair[0]; j++){ send(i * (1 << 2) + 0); } for(int j=0; j<pair[1]; j++){ send(i * (1 << 2) + 1); } for(int j=0; j<pair[2]; j++){ send(i * (1 << 2) + 2); } for(int j=0; j<pair[3]; j++){ send(i * (1 << 2) + 3); } } void encode(int n, int m[]){ bool zero = false; int cnt_zero = 4, cnt_one = 0; for(int i=0; i<n; i++){ vector<int> bit(8, 0); for(int j=0; j<8; j++){ if(m[i] & (1 << j)){ bit[j] = 1; } } for(int j=0; j<8; j+=2){ if(!bit[j] && !bit[j + 1]) cnt_zero += 3; if(!bit[j] && bit[j + 1]) cnt_zero += 2, cnt_one ++; if(bit[j] && !bit[j + 1]) cnt_zero += 1, cnt_one += 2; if(bit[j] && bit[j + 1]) cnt_one += 3; } } if(cnt_one > cnt_zero){ zero = true; for(int i=0; i<4; i++) send(0); } for(int i=0; i<n; i++){ solve(m[i], i, zero); } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int n, int l, int x[]){ vector<vector<int>> id(n); int cnt_zero = 0; bool zero = false; for(int i=0; i<l; i++){ if(x[i] == 0) cnt_zero ++; } if(cnt_zero >= 4) zero = true; for(int i=0; i<l; i++){ id[x[i] >> 2].push_back(x[i] % 4); } if(zero){ for(int i=0; i<n; i++){ vector<int> pair(4, 0); if(!id[i].empty()){ for(auto k : id[i]){ pair[k] ++; } } if(zero && i == 0) pair[0] -= 4; int ans = 0; for(int j=0; j<4; j++){ if(pair[j] == 2) ans += (1 << (2 * j)); if(pair[j] == 1) ans += (1 << (2 * j + 1)); if(pair[j] == 0) ans += (1 << (2 * j)) + (1 << (2 * j + 1)); } output(ans); } } else{ for(int i=0; i<n; i++){ vector<int> pair(4, 0); if(!id[i].empty()){ for(auto k : id[i]){ pair[k] ++; } } int ans = 0; for(int j=0; j<4; j++){ if(pair[j] == 1) ans += (1 << (2 * j)); if(pair[j] == 2) ans += (1 << (2 * j + 1)); if(pair[j] == 3) ans += (1 << (2 * j)) + (1 << (2 * j + 1)); } output(ans); } } }
#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...