이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*DavitMarg*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
#ifndef death
#include "encoder.h"
#include "encoderlib.h"
#include "decoder.h"
#include "decoderlib.h"
#endif
#ifdef death
const int N = 100;
int X[N], L;
void send(int a)
{
X[L++] = a;
cout << "!send " << a << endl;
}
void output(int a)
{
cout << "!output " << a << endl;
}
#endif // death
int seed = 578478;
void encode(int n, int x[])
{
srand(seed);
vector<int> add;
for (int i = 0; i < n; i++)
{
int j = 0;
int a = x[i];
while (a)
{
int c = a % 4;
while (c--)
add.PB(i * 4 + j);
a /= 4;
j++;
}
}
if (add.size() > 2 * n * 3)
{
send(255);
send(255);
send(255);
send(255);
add.clear();
for (int i = 0; i < n; i++)
{
int j = 0;
int a = 255 - x[i];
while (a)
{
int c = a % 4;
while (c--)
add.PB(i * 4 + j);
a /= 4;
j++;
}
}
}
while (!add.empty())
{
send(add.back());
add.pop_back();
}
}
#ifdef death
int main()
{
int nn, xx[N];
cin >> nn;
for (int i = 0; i < nn; i++)
cin >> xx[i];
encode(nn, xx);
decode(nn, L, X);
return 0;
}
#endif
/*
*/
/*DavitMarg*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
#ifndef death
#include "encoder.h"
#include "encoderlib.h"
#include "decoder.h"
#include "decoderlib.h"
#endif
#ifdef death
const int N = 100;
int X[N], L;
void send(int a)
{
X[L++] = a;
cout << "!send " << a << endl;
}
void output(int a)
{
cout << "!output " << a << endl;
}
#endif // death
int seed = 578478;
void decode(int n,int l,int x[])
{
srand(seed);
int p[5];
p[0] = 1;
p[1] = 4;
p[2] = 16;
p[3] = 64;
vector<int> res(n);
vector<int> used(300);
for (int i = 0; i < l; i++)
used[x[i]]++;
if (used[255] >= 4)
{
for (int i = 0; i < n; i++)
res[i] = 255;
srand(seed);
sort(x, x + l);
l -= 4;
for (int i = 0; i < l; i++)
{
int pos = x[i] / 4;
int add = x[i] % 4;
res[pos] -= p[add];
}
}
else
{
for (int i = 0; i < l; i++)
{
int pos = x[i] / 4;
int add = x[i] % 4;
res[pos] += p[add];
}
}
for (int i = 0; i < n; i++)
output(res[i]);
}
#ifdef death
int main()
{
int nn, xx[N];
cin >> nn;
for (int i = 0; i < nn; i++)
cin >> xx[i];
encode(nn, xx);
decode(nn, L, X);
return 0;
}
#endif
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:78:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (add.size() > 2 * n * 3)
~~~~~~~~~~~^~~~~~~~~~~
# | 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... |