Submission #58668

#TimeUsernameProblemLanguageResultExecution timeMemory
58668kingpig9Parrots (IOI11_parrots)C++11
Compilation error
0 ms0 KiB
//START COPY #include <bits/stdc++.h> using namespace std; typedef bitset<576> bset; static void operator += (bset &b1, bset b2) { bool carry = 0; for (int i = 0; i < 576; i++) { int x = int(b1[i]) + int(b2[i]) + carry; b1[i] = bool(x & 1); carry = (x >= 2); } } static void operator -= (bset &b1, bset b2) { //b1 + (~b2) + 1 //optimize the +1 for (int i = 0; i < 576; i++) { if (!b1[i]) { b1[i] = true; for (int j = 0; j < i; j++) { b1[j] = false; } break; } } b1 += (~b2); } static bset operator + (bset b1, bset b2) { b1 += b2; return b1; } static bset operator - (bset b1, bset b2) { b1 -= b2; return b1; } static bool operator < (bset b1, bset b2) { for (int i = 575; i >= 0; i--) { if (b1[i] < b2[i]) { return true; } if (b1[i] > b2[i]) { return false; } } return false; } static bool operator >= (bset b1, bset b2) { return !(b1 < b2); } static bool operator > (bset b1, bset b2) { return b2 < b1; } static bool operator <= (bset b1, bset b2) { return !(b2 < b1); } static bset cho[576][256]; static void precomp() { for (int i = 0; i < 576; i++) { cho[i][0][0] = 1; for (int j = 1; j <= i && j < 256; j++) { cho[i][j] = cho[i - 1][j] + cho[i - 1][j - 1]; } } } static bset nsum (int n, int s) { return cho[n + s - 1][n - 1]; } static int N; static int K; //END COPY void encode (int nn, int mm[]) { N = nn; K = 5 * N; precomp(); //ok let's go! bset rnk = bset(); for (int i = 0; i < N; i++) { rnk |= (bset(mm[i]) << (8 * i)); } //ok now get this number rank vector<int> ans; for (int i = 0; i < K; i++) { //if you put this one then what will you get? int prv = (ans.empty() ? 0 : ans.back()); for (int j = prv; j < 256; j++) { //test if next one is > j. //if not then choose this one and break bset nways = nsum(256 - j, K - 1 - i); if (rnk >= nways) { rnk -= nways; } else { ans.push_back(j); break; } } } //printf("SEND:"); for (int x : ans) { //printf(" %d", x); send(x); } //printf("\n"); }
//START COPY #include <bits/stdc++.h> using namespace std; typedef bitset<576> bset; static void operator += (bset &b1, bset b2) { bool carry = 0; for (int i = 0; i < 576; i++) { int x = int(b1[i]) + int(b2[i]) + carry; b1[i] = bool(x & 1); carry = (x >= 2); } } static void operator -= (bset &b1, bset b2) { //b1 + (~b2) + 1 //optimize the +1 for (int i = 0; i < 576; i++) { if (!b1[i]) { b1[i] = true; for (int j = 0; j < i; j++) { b1[j] = false; } break; } } b1 += (~b2); } static bset operator + (bset b1, bset b2) { b1 += b2; return b1; } static bset operator - (bset b1, bset b2) { b1 -= b2; return b1; } static bool operator < (bset b1, bset b2) { for (int i = 575; i >= 0; i--) { if (b1[i] < b2[i]) { return true; } if (b1[i] > b2[i]) { return false; } } return false; } static bool operator >= (bset b1, bset b2) { return !(b1 < b2); } static bool operator > (bset b1, bset b2) { return b2 < b1; } static bool operator <= (bset b1, bset b2) { return !(b2 < b1); } static bset cho[576][256]; static void precomp() { for (int i = 0; i < 576; i++) { cho[i][0][0] = 1; for (int j = 1; j <= i && j < 256; j++) { cho[i][j] = cho[i - 1][j] + cho[i - 1][j - 1]; } } } static bset nsum (int n, int s) { return cho[n + s - 1][n - 1]; } static int N; static int K; //END COPY void decode (int nn, int kk, int X[]) { N = nn; K = kk; precomp(); //find the rank of this one bset rnk = bset(); for (int i = 0; i < K; i++) { int prv = (i == 0 ? 0 : X[i - 1]); for (int j = prv; j < X[i]; j++) { //add this amount of stuff bset nways = nsum(256 - j, K - 1 - i); rnk += nways; } } //printf("OUTPUT:"); for (int i = 0; i < N; i++) { //ok let's do this int val = (rnk & bset(255)).to_ulong(); //printf(" %d", val); output(val); rnk >>= 8; } //printf("\n"); }

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:117:3: error: 'send' was not declared in this scope
   send(x);
   ^~~~
encoder.cpp:117:3: note: suggested alternative: 'setns'
   send(x);
   ^~~~
   setns
encoder.cpp: At global scope:
encoder.cpp:62:13: warning: 'bool operator<=(bset, bset)' defined but not used [-Wunused-function]
 static bool operator <= (bset b1, bset b2) {
             ^~~~~~~~
encoder.cpp:58:13: warning: 'bool operator>(bset, bset)' defined but not used [-Wunused-function]
 static bool operator > (bset b1, bset b2) {
             ^~~~~~~~
encoder.cpp:37:13: warning: 'bset operator-(bset, bset)' defined but not used [-Wunused-function]
 static bset operator - (bset b1, bset b2) {
             ^~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:106:3: error: 'output' was not declared in this scope
   output(val);
   ^~~~~~
decoder.cpp:106:3: note: suggested alternative: 'getpt'
   output(val);
   ^~~~~~
   getpt
decoder.cpp: At global scope:
decoder.cpp:62:13: warning: 'bool operator<=(bset, bset)' defined but not used [-Wunused-function]
 static bool operator <= (bset b1, bset b2) {
             ^~~~~~~~
decoder.cpp:58:13: warning: 'bool operator>(bset, bset)' defined but not used [-Wunused-function]
 static bool operator > (bset b1, bset b2) {
             ^~~~~~~~
decoder.cpp:54:13: warning: 'bool operator>=(bset, bset)' defined but not used [-Wunused-function]
 static bool operator >= (bset b1, bset b2) {
             ^~~~~~~~
decoder.cpp:37:13: warning: 'bset operator-(bset, bset)' defined but not used [-Wunused-function]
 static bset operator - (bset b1, bset b2) {
             ^~~~~~~~