# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225696 | davitmarg | Parrots (IOI11_parrots) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*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
void encode(int n, int x[])
{
for (int i = 0; i < n; i++)
{
int j = 0;
while (x[i])
{
int c = x[i] % 4;
while (c--)
send(i * 4 + j);
x[i] /= 4;
j++;
}
}
}
void decode(int n,int l,int x[])
{
int p[5];
p[0] = 1;
p[1] = 4;
p[2] = 16;
p[3] = 64;
vector<int> res(n);
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
/*
*/
/*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
void encode(int n, int x[])
{
for (int i = 0; i < n; i++)
{
int j = 0;
while (x[i])
{
int c = x[i] % 4;
while (c--)
send(i * 4 + j);
x[i] /= 4;
j++;
}
}
}
void decode(int n,int l,int x[])
{
int p[5];
p[0] = 1;
p[1] = 4;
p[2] = 16;
p[3] = 64;
vector<int> res(n);
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
/*
*/