#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
typedef long long lLong;
typedef unsigned long uLong;
typedef unsigned long long ulLong;
typedef unsigned int uInt;
typedef unsigned char Byte;
using namespace std;
typedef vector<int> VI;
#define MAX_N 1048578
class PrzypadekTestowy
{
private:
uInt _n;
uInt _liczbaKart;
uLong _k;
int _karty[MAX_N];
bool _czyPrzelozyc;
FILE *_input;
inline void Reset()
{
}
inline void WczytajInt(int *value)
{
fscanf(_input, "%d\n", value);
}
public:
PrzypadekTestowy() :_input(stdin)
{
}
PrzypadekTestowy(FILE *input)
{
_input = input;
}
inline void Wykonaj()
{
Reset();
WczytajPrzypadekTestowy();
WypiszWynik();
}
inline void WypiszWynik()
{
if (_czyPrzelozyc)
{
for (int i=_liczbaKart-1;i>=0;i--)
{
printf("%d ", _karty[i]);
}
}
else
{
for (uInt i = 0; i < _liczbaKart; i++)
{
printf("%d ", _karty[i]);
}
}
printf("\n");
}
inline void WczytajPrzypadekTestowy()
{
fscanf(_input, "%d %ld\n", &_n, &_k);
_liczbaKart = (uInt)pow(2, _n);
_czyPrzelozyc = _k % 2 != 0;
for (uInt i = 0; i < _liczbaKart; i++)
{
WczytajInt((_karty+i));
}
}
};
int main(int argc, char **argv)
{
FILE *in = stdin;
if (argc>1)
{
in = fopen(argv[1], "rt");
if (NULL == in)
{
in = stdin;
}
}
PrzypadekTestowy *p = new PrzypadekTestowy(in);
p->Wykonaj();
fclose(in);
delete(p);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <stdio.h> #include <iostream> #include <string.h> #include <math.h> #include <algorithm> #include <vector> typedef long long lLong; typedef unsigned long uLong; typedef unsigned long long ulLong; typedef unsigned int uInt; typedef unsigned char Byte; using namespace std; typedef vector<int> VI; #define MAX_N 1048578 class PrzypadekTestowy { private: uInt _n; uInt _liczbaKart; uLong _k; int _karty[MAX_N]; bool _czyPrzelozyc; FILE *_input; inline void Reset() { } inline void WczytajInt(int *value) { fscanf(_input, "%d\n", value); } public: PrzypadekTestowy() :_input(stdin) { } PrzypadekTestowy(FILE *input) { _input = input; } inline void Wykonaj() { Reset(); WczytajPrzypadekTestowy(); WypiszWynik(); } inline void WypiszWynik() { if (_czyPrzelozyc) { for (int i=_liczbaKart-1;i>=0;i--) { printf("%d ", _karty[i]); } } else { for (uInt i = 0; i < _liczbaKart; i++) { printf("%d ", _karty[i]); } } printf("\n"); } inline void WczytajPrzypadekTestowy() { fscanf(_input, "%d %ld\n", &_n, &_k); _liczbaKart = (uInt)pow(2, _n); _czyPrzelozyc = _k % 2 != 0; for (uInt i = 0; i < _liczbaKart; i++) { WczytajInt((_karty+i)); } } }; int main(int argc, char **argv) { FILE *in = stdin; if (argc>1) { in = fopen(argv[1], "rt"); if (NULL == in) { in = stdin; } } PrzypadekTestowy *p = new PrzypadekTestowy(in); p->Wykonaj(); fclose(in); delete(p); return 0; } |
English