This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <string>
using namespace std;
void encode(int N, int M[])
{
vector<bool> message;
for(int i = 0; i < N; i++){
for (int j = 7; j >= 0; j--){
message.push_back((M[i] & (1 << j)));
}
}
// for (int i = 0; i < N; i++){
// cout << M[i] << ' ';
// }
// cout << endl;
//
// for (int i = 0; i < message.size(); i++){
// cout << message[i] << ' ';;
// }
// cout << endl;
for (int i = 0; i < 2 * N; i++){
int to_send = 8 * message[4 * i] + 4 * message[4 * i + 1] + 2 * message[4 * i + 2] + message[4 * i + 3];
for (int k = 0; k < 5; k++){
if (to_send >= 3){
to_send -= 3;
send(4 * i + 3);
} else {
if (to_send == 2){
to_send -=2;
send(4 * i + 2);
} else{
if (to_send == 1){
to_send -=1;
send(4 * i + 1);
} else{
send(4 * i);
}
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
using namespace std;
//bool pairc
void decode(int N, int L, int X[])
{
vector<pair<int, int> > recieved;
vector<int> full_recieved;
for(int i=0; i<L; i++) {
recieved.push_back(make_pair(X[i] >> 2, X[i] & 3));
}
sort(recieved.begin(), recieved.end());
for (int i = 0; i < recieved.size(); i++){
//cout << recieved[i].first << " : " << recieved[i].second << endl;
full_recieved.push_back(recieved[i].second);
//cout << 'r' << recieved[i].second << endl;
}
for (int i = 0; i < N; i++){
int s1 = full_recieved[10 * i];
int s2 = full_recieved[10 * i + 1];
int s3 = full_recieved[10 * i + 2];
int s4 = full_recieved[10 * i + 3];
int s5 = full_recieved[10 * i + 4];
int t1 = full_recieved[10 * i + 5];
int t2 = full_recieved[10 * i + 6];
int t3 = full_recieved[10 * i + 7];
int t4 = full_recieved[10 * i + 8];
int t5 = full_recieved[10 * i + 9];
// cout << i << " : " << s1 + s2 + s3 + s4 + s5 << endl;
// cout << i << " t: " << t1 + t2 + t3 + t4 + t5 << endl;
// cout << ((s1 + s2 + s3 + s4 + s5) << 4) + (t1 + t2 + t3 + t4 + t5) << endl;
output(((s1 + s2 + s3 + s4 + s5) << 4) + (t1 + t2 + t3 + t4 + t5));
}
}
Compilation message (stderr)
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:26:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < recieved.size(); i++){
~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |