이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int SIZE = 8;
const int ORDERBITS = 5;
int pows2[] = { 1,2,4,8,16,32,64,128 };
void send(int a);
void output(int b);
inline int readid(int num) {
for (int i = SIZE - 1; i >= ORDERBITS; i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
}
}
return num;
}
inline int readBit(int num) {
int ans = 0;
for (int i = SIZE - 1; i >= ORDERBITS; i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
ans += pows2[i - ORDERBITS];
}
}
return ans;
}
inline int getShift(int num) {
int ans = 0;
for (int i = SIZE - ORDERBITS - 1;i >= 0;i--) {
if (num - pows2[i] >= 0) {
ans += pows2[i + ORDERBITS];
num -= pows2[i];
}
}
return ans;
}
inline void sendForNum(int num, int index) {
for (int i = SIZE - 1;i >= 0;i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
int curr = index + getShift(i);
send(curr);
}
}
}
void encode(int N, int M[]) {
vi arr(N);
for (int i = 0;i < N;i++) {
arr[i] = M[i];
}
sort(arr.begin(), arr.end());
for (int i = 0;i < N;i++) {
sendForNum(arr[i], i);
}
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int SIZE = 8;
const int ORDERBITS = 5;
int pows2[] = { 1,2,4,8,16,32,64,128 };
void send(int a);
void output(int b);
inline int readid(int num) {
for (int i = SIZE - 1; i >= ORDERBITS; i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
}
}
return num;
}
inline int readBit(int num) {
int ans = 0;
for (int i = SIZE - 1; i >= ORDERBITS; i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
ans += pows2[i - ORDERBITS];
}
}
return ans;
}
inline int getShift(int num) {
int ans = 0;
for (int i = SIZE - ORDERBITS - 1;i >= 0;i--) {
if (num - pows2[i] >= 0) {
ans += pows2[i + ORDERBITS];
num -= pows2[i];
}
}
return ans;
}
inline void sendForNum(int num, int index) {
for (int i = SIZE - 1;i >= 0;i--) {
if (num - pows2[i] >= 0) {
num -= pows2[i];
int curr = index + getShift(i);
send(curr);
}
}
}
void decode(int N, int L, int X[]) {
vi arr(N);
for (int i = 0;i < L;i++) {
int index = readid(X[i]);
arr[index] += pows2[readBit(X[i])];
}
for (int i = 0;i < arr.size();i++) {
output(arr[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int i = 0;i < arr.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... |